Set - 3

Question 6 :

How can I set a cookie and delete a cookie from within a JSP page?

Answer :

A cookie, mycookie, can be deleted using the following scriptlet:


Question 7 :

How do you connect to the database from JSP?

Answer :

A Connection to a database can be established from a jsp page by writing the code to establish a connection using a jsp scriptlets.
Further then you can use the resultset object "res" to read data in the following way.


Question 8 :

What is the page directive is used to prevent a JSP page from automatically creating a session?

Answer :

<%@ page session="false">


Question 9 :

How do you delete a Cookie within a JSP?

Answer :

Cookie mycook = new Cookie("name","value");
response.addCookie(mycook);
Cookie killmycook = new Cookie("mycook","value");
killmycook.setMaxAge(0);
killmycook.setPath("/");
killmycook.addCookie(killmycook);


Question 10 :

Can we implement an interface in a JSP?

Answer :

No