How you can perform browser redirection?
You can perform browser redirection using sendRedirect() method on response object in the servlet. Example :
You can also physically alter the Location HTTP header attribute, as shown below:
String newLocn = "/newpath/index.html";
How will you include a static file in a JSP page?
You can include a static file in a JSP page by using include directive :
<%@ include file="relativeURL" %>Reply
How will you delete a cookie?
To delete cookie from servlet, get the cookie from the request object and use setMaxAge(0) and then add the cookie to the response object.
To delete cookie from JSP, use the following scriptlet:
Cookie killMyCookie = new Cookie("mycookie", null);
How can I set a cookie?
You can set the cookie by setValue() method on cookie object.
cookie.setValue("My own value");Reply
How do you pass data (including JavaBeans) to a JSP from a servlet?
You can pass information to a JSP page from the servlet. Using setAttribut() on request object in the servlet and forward it as follows :
RequestDispatcher rd =
How to pass information from JSP to included JSP?
You can pass information from JSP to the included JSP using the <jsp:param> in the body of <jsp:include> action.
<jsp:param name="parameterName" value="parameterValue"/>
What is a Hidden Comment?
A hidden comment is a JSP comment that is not sent to the client. Syntax :
<%-- Hidden comment --%>Reply
What is the difference between ServletContext and ServletConfig?
ServletContext and ServletConfig are declared in the deployment descriptor. ServletConfig is one per servlet and can be accessed only within that specific servlet. ServletContext is one per web application and accessible to all the servlet in the web application.Reply
What are JSP Actions?
JSP Actions are XML tags that are executed at run time. These tags transfer the control between the pages and also use the server side beans :
Some JSP Actions are :
How do I use a scriptlet to initialize a newly instantiated bean?
The <jsp:useBean> may also optionally have a body. You can make use of a JSP expression within the <jsp:setProperty> action in the body of <jsp:useBean>.
For Example :
<jsp:useBean id="foo" class="Bar.Foo" >
<jsp:setProperty name="foo" property="today" value="<%=java.text.DateFormat.getDateInstance().format(new java.util.Date()) %>" / >
</jsp:useBean > Reply