Skip to main content

Posts

Showing posts with the label JSP

JSP Interview Questions part - 2

JSP Interview Questions 1. How will you implement error page in JSP? To implement an error-handling page in JSP, we first create a JSP with error page handling information. In most of the cases we gracefully handle error by giving a user-friendly message like “Sorry! There is system error. Please try again by refreshing page.” In this error page, we show user-friendly message to user, but we also log important information like stack trace to our application log file. We have to add parameter isErrorPage=true in page directive of this page. This tells to JSP container that this is our error page. <%@page isErrorPage=”true” %> Now we can use this error page in other JSP where we want to handle error. In case of an error or exception, these JSP will direct it to errorPage.            <% page errorPage=”ErrorPage.jsp” %> 2. How will you send XML data from a JSP? In general, JSP is used to pass HTML data to web browser. I...

JSP Interview Questions

JSP Interview Questions 1. What are the implicit objects in JSP? JSP has following implicit objects: 1. Request 2. Response 3. Application 4. Exception 5. Page 6. Config 7.  Session 2. How will you extend JSP code? We can extend JSP code by using Tag libraries and Custom actions. 3. How will you handle runtime exceptions in JSP? We use Errorpage attribute in JSP to catch runtime exceptions. This attribute forwards user request to the error page automatically. 4. How will you prevent multiple submits of a page that come by clicking refresh button multiple times? We can use Post Redirect Get (PRG) pattern to solve the issue of multiple submission of same data. It works as follows: First time when a user submits a form to server by POST or GET method, then we update the state in application database. Then we send a redirect response to send reply to client. Then we load a view by using GET command. There is no data is sent in this. Since ...