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
How to refer the "this" variable within a JSP page?
Under JSP 1.0, the "page" implicit object page is equivalent to "this", and returns a reference to the servlet generated by the JSP page. Reply
How do I prevent the output of my JSP or Servlet pages from being cached by the browser?
By setting HTTP header attributes you can prevent the output of my JSP or Servlet pages from being cached by the browser. You can do this by the following code :
response.setHeader("Cache-Control","no-cache"); //HTTP 1.1
response.setHeader("Pragma","no-cache"); //HTTP 1.0
response.setDateHeader ("Expires", 0); //prevents caching at the proxy server