27. Do we have a constructor in servlet? Can we explicitly provide a constructor in servlet program as in java
program?
We can have a constructor in servlet .
Session : A session is a group of activities that are performed by a user while accesing a particular website.
Session Tracking :The process of keeping track of settings across session is called session tracking.
Hidden Form Fields : Used to keep track of users by placing hidden fields in the form.
-The values that have been entered in these fields are sent to the server when the user submits the Form.
URL-rewriting : this is a technique by which the URL is modified to include the session ID of a particular user and is sent back to the Client.
-The session Id is used by the client for subsequent transactions with the server.
Cookies : Cookies are small text files that are used by a webserver to keep track the Users.
A cookie is created by the server and send back to the client , the value is in the form of Key-value pairs. Aclient can accept 20 cookies per host and the size of each cookie can be maximum of 4 bytes each.
HttpSession : Every user who logs on to the website is autometacally associated with an HttpSession Object.
-The Servlet can use this Object to store information about the users Session.
-HttpSession Object enables the user to maintain two types of Data.
i.e. State and Application.
28. How to communicate between two servlets?
Two ways:
a). Forward or redirect from one Servlet to another.
b). Load the Servlet from ServletContext and access methods.
29. How to get one Servlet's Context Information in another Servlet?
Access or load the Servlet from the Servlet Context and access the Context Information.
30. The following code snippet demonstrates the invocation of a JSP error page from within a controll servlet?
protected void sendErrorRedirect(HttpServletRequest request,
HttpServletResponse response, String errorPageURL, Throwable e) throws
ServletException, IOException {
request.setAttribute ("javax.servlet.jsp.jspException", e);
getServletConfig().getServletContext().
getRequestDispatcher(errorPageURL).forward(request, response);
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
{
try {
// do something
} catch (Exception ex) {
try {
sendErrorRedirect(request,response,"/jsp/MyErrorPage.jsp",ex);
} catch (Exception e) {
e.printStackTrace();
}
}
}
program?
We can have a constructor in servlet .
Session : A session is a group of activities that are performed by a user while accesing a particular website.
Session Tracking :The process of keeping track of settings across session is called session tracking.
Hidden Form Fields : Used to keep track of users by placing hidden fields in the form.
-The values that have been entered in these fields are sent to the server when the user submits the Form.
URL-rewriting : this is a technique by which the URL is modified to include the session ID of a particular user and is sent back to the Client.
-The session Id is used by the client for subsequent transactions with the server.
Cookies : Cookies are small text files that are used by a webserver to keep track the Users.
A cookie is created by the server and send back to the client , the value is in the form of Key-value pairs. Aclient can accept 20 cookies per host and the size of each cookie can be maximum of 4 bytes each.
HttpSession : Every user who logs on to the website is autometacally associated with an HttpSession Object.
-The Servlet can use this Object to store information about the users Session.
-HttpSession Object enables the user to maintain two types of Data.
i.e. State and Application.
28. How to communicate between two servlets?
Two ways:
a). Forward or redirect from one Servlet to another.
b). Load the Servlet from ServletContext and access methods.
29. How to get one Servlet's Context Information in another Servlet?
Access or load the Servlet from the Servlet Context and access the Context Information.
30. The following code snippet demonstrates the invocation of a JSP error page from within a controll servlet?
protected void sendErrorRedirect(HttpServletRequest request,
HttpServletResponse response, String errorPageURL, Throwable e) throws
ServletException, IOException {
request.setAttribute ("javax.servlet.jsp.jspException", e);
getServletConfig().getServletContext().
getRequestDispatcher(errorPageURL).forward(request, response);
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
{
try {
// do something
} catch (Exception ex) {
try {
sendErrorRedirect(request,response,"/jsp/MyErrorPage.jsp",ex);
} catch (Exception e) {
e.printStackTrace();
}
}
}