Blog Archives

What is a filter in JSP?

We can define filters in JSP to intercept requests from a client or to change response from a server. Filter is a Java class that is defined in the deployment descriptor of web.xml of an application. The JSP container reads

Posted in JSP, JSP Interview Questions

How can you upload a large file in JSP?

To upload a file by JSP we can use <input type=”file”> in the Form data being passed from HTML. If the file is very large in size, we can set enctype=multipart/form-data. We have to use POST method in the Form

Posted in JSP, JSP Interview Questions

In which scenario, Container initializes multiple JSP/Servlet objects?

To initialize multiple JSP objects, we have to specify same Servlet object multiple times in web.xml. This indicates to JSP container to initialize separate JSP/Servlet object for each element. Each of the Servlet instance will have its own ServletConfig object

Posted in JSP, JSP Interview Questions

What is the difference between sendRedirect and forward in a JSP?

Both forward and sendRedirect are mechanisms of sending a client to another page. The main difference between these two are as follows: <li>In forward, the processing takes place at server side. In case of sendRedirect() the processing takes place the

Posted in JSP, JSP Interview Questions

What is the use of config implicit object in JSP?

In JSP, config object is of type ServletConfig. This object is created by Servlet Container for each JSP page. It is used for setting initialization parameters for a specific JSP page.

Posted in JSP, JSP Interview Questions

What is the difference between init-param and context-param?

We can specify both init-param and context-param in web.xml file. We use init-param to specify the parameters that are specific to a servlet or jsp. This information is confined to the scope of that JSP. We use context-param to specify

Posted in JSP, JSP Interview Questions

What is the purpose of RequestDispatcher?

We use RequestDispatcher interface to forward requests to other resources like HTML, JSP etc. It can also be used to include the content of another page in a JSP. It has two methods: forward and include. We have to first

Posted in JSP, JSP Interview Questions

How can be read data from a Form in a JSP?

There is a built-in request object in a JSP that provides methods to read Form data. Some of the methods are as follows:: getParameterNames(): This method returns the list of all the parameters in the Form. getParameter(): We call this

Posted in JSP, JSP Interview Questions

How will you prevent caching of HTML output by web browser in JSP?

We can use set the header in response object for Cache-Control to specify no caching. Sample code is as follows: response.setHeader(“Cache-Control”, “no-store”); response.setDateHeader(“Expires”,”0”);

Posted in JSP, JSP Interview Questions

How will you redirect request to another page in browser in JSP code?

We can use sendRedirect() method in JSP to redirect the request to another location or page. In this case the request will not come back to server. It will redirect in the browser itself. Sample code is as follows: <%

Posted in JSP, JSP Interview Questions