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);
killMyCookie.setMaxAge(0);
killMyCookie.setPath("/");
response.addCookie(killMyCookie);
%>
Reply
Posted By:
Name:Rajesh Kr
You can set the cookie by setValue() method on cookie object.
Example :
cookie.setValue("My own value");
Reply
Posted By:
Name:Rajesh Kr
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 =
getServletContext().getRequestDispatcher("test.jsp");
rd.forward(request,response);
Reply
Posted By:
Name:Rajesh Kr
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.
Example :
<jsp:include page="relativeURL">
<jsp:param name="parameterName" value="parameterValue"/>
</jsp:include>
Reply
Posted By:
Name:Rajesh Kr
A hidden comment is a JSP comment that is not sent to the client. Syntax :
<%-- Hidden comment --%>
Reply
Posted By:
Name:Rajesh Kr
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
Posted By:
Name:Rajesh Kr
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 :
* jsp:include,
* jsp:useBean,
* jsp:setProperty,
* jsp:getProperty,
* jsp:forward,
* jsp:plugin.
Reply
Posted By:
Name:Rajesh Kr
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
Posted By:
Name:Rajesh Kr
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
Posted By:
Name:Rajesh Kr
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
%>
Reply
Posted By:
Name:Rajesh Kr