Given source code used for accessing file from server using
Servlets
String path = getServletContext( ).getRealPath ("xyz.xml" ) ;
System.out.println ( path ) ;
File file = new File ( path ) ;
JSP
String path = application.getRealPath ("xyz.xml" ) ;
System.out.println ( path ) ;
File file = new File ( path ) ;
In above jsp code, "application" is jsp implicit object.
I am publishing android applications developed by me using this blog. This blog also has collection of technical resources for java, j2ee, spring, hibernate
Showing posts with label jsp. Show all posts
Showing posts with label jsp. Show all posts
Monday, May 3, 2010
Saturday, April 10, 2010
Difference between GET Method and POST Method
GET Method
- Target resource type is Active or passive
- Type of data is Text
- The amount of data handled by GET Method is not more than 255 characters.
- Data is part of the URL and is visible to the user in the URL field of browser.
- Data can be cached in the browser's URL History.
- Target resource type is Active
- Type of data is Text as well as Binary
- The amount of data handled by POST Method is unlimited.
- Data is not a part of the URL and is sent as the request message body. It is not visible to the user in the URL field of browser.
- Data is not cached in the browser's URL History.
Monday, February 15, 2010
JSP Life Cycle
1. JSP Page Translation:
A java servlet file is generated from the JSP source file. This is the first step in its tedious multiple phase life cycle. In the translation phase, the container validates the syntactic correctness of the JSP pages and tag files. The container interprets the standard directives and actions, and the custom actions referencing tag libraries used in the page.2. JSP Page Compilation:
The generated java servlet file is compiled into a java servlet class.Note: The translation of a JSP source page into its implementation class can happen at any time between initial deployment of the JSP page into the JSP container and the receipt and processing of a client request for the target JSP page.
3. Class Loading:
The java servlet class that was compiled from the JSP source is loaded into the container.4. Execution phase:
In the execution phase the container manages one or more instances of this class in response to requests and other events.The interface JspPage contains jspInit() and jspDestroy(). The JSP specification has provided a special interface HttpJspPage for JSP pages serving HTTP requests and this interface contains _jspService().
5. Initialization:
jspInit() method is called immediately after the instance was created. It is called only once during JSP life cycle.6. _jspService() execution:
This method is called for every request of this JSP during its life cycle. This is where it serves the purpose of creation. Oops! it has to pass through all the above steps to reach this phase. It passes the request and the response objects. _jspService() cannot be overridden.7. jspDestroy() execution:
This method is called when this JSP is destroyed. With this call the servlet serves its purpose and submits itself to heaven (garbage collection). This is the end of jsp life cycle.jspInit(), _jspService() and jspDestroy() are called the life cycle methods of the JSP.
Subscribe to:
Posts (Atom)