There is no difference between JSP and Servlet.
(1) Request Lifetime:
Using this technique to pass beans, a request dispatcher (using either "include" or "forward") can be called. This bean will disappear after processing this request has been completed.
request. setAttribute("theBean", myBean);
RequestDispatcher rd = getServletContext(). getRequestDispatcher("thepage.jsp");
rd. forward(request, response);
(2) Session Lifetime: Using this technique to pass beans that are relevant to a particular session (such as in individual user login) over a number of requests. This bean will disappear when the session is invalidated or it times out, or when you remove it.
Servlet: HttpSession session = request. getSession(true);
session. putValue("theBean", myBean); /* You can do a request dispatcher here, or just let the bean be visible on the next request */
(3) Application Lifetime: Using this technique to pass beans that are relevant to all servlets and JSP pages in a particular app, for all users. For example, I use this to make a JDBC connection pool object available to the various servlets and JSP pages in my apps. This bean will disappear when the servlet engine is shut down, or when you remove it.
Servlet: GetServletContext(). setAttribute("theBean", myBean); JSP PAGE:
JSP pages are focused around HTML (or XML) with Java codes and JSP tags inside them. When a web server that has JSP support is asked for a JSP page, it checks to see if it has already compiled the page into a servlet. Thus, JSP pages become servlets and are transformed into pure Java and then compiled, loaded into the server and executed.
It forward current request to another page. Following is the syntax :
iText, a JAVA-PDF library - This library contains classes that generate documents in the Portable Document Format (PDF) and/or HTML. (There are lot of other tools are there in market )
YES. JSP technology is extensible through the development of custom actions, or tags, which are encapsulated in tag libraries
Servlet can interact with jsp using following code snippet: getServletConfig().getServletContext().getRequestDispatcher ("/jsp/Bean1.jsp").forward(request, response);
<jsp:usebean id="beanID" class="fully qualified
class name" scope="page|request|session|application">
<jsp:setProperty name="id" property="someProperty" value="someValue">
<jsp:getProperty name="id" property="someProperty">
JSP Translation Time Errors. JSP Request Time Errors. Errors can occur in a JSP in two different phases of its life. The first type of error, which occurs during the initial request, is known as a translation time error . The second type of JSP error occurs during subsequent requests and is know as a request time error .
Ads By Google
© 2018 - JavaSpartans.com • All Rights Reserved