JspApp
-WEB-INF
--web.xml
-ABC.jsp
- Providing url-pattern to jsp is optional but you can provide url-pattern by writing following code in web.xml
- The page compilers of jsp scans source code of jsp and generates jsp equivalent servlet.
- From programmer point of view there are some jsp files. From webcontainer point of view there are jsp equivalent servlet files.
- The java code of scriptlet available in the jsp will be scanned by page compiler as it is. It will be placed in jsp equivalent servlet's _jspService().
1. jspInit()
2. _jspService(req,res)
3. jspDestroy
This is life cycle of jsp.
- In Tomcat webserver Jsp equivalent Servlet will be generated in the following folder for ABC.jsp of JspApp web application.
D:\>Tomcat\work\catalina\localhost\JspApp\org\apache\jsp\ABC_jsp.java
- Here JspApp is web application name,org is package name and ABC_jsp.java is a file where jsp equivalent servlet will be stored.
- In different servers the class name of jsp equivalent servlet will be generated with different names. In Tomcat for x.jsp Jsp equivalent servlet class name is x_jsp.
- The jsp equivalent servlet generated by any page compiler is always HttpServlet.
- In weblogic server the jsp equivalent servlet class name is for ABC.jsp is --ABC.
- when you deploy web application in example server domain of weblogic. The jsp equivalent servlet will be generated in the following file and in the following directory.
D:\bea\weblogic81\samples\domains\examples\exampleserver\.wlnotdelete\extract\examplesServer_appsdir_JspApp_dir_JspApp\JspServlet\_abc.java
Note:- The weblogic server deletes jsp equivalent Servlet source code (.java) one's .class file is generated.
- We can use Java Decompilers to get java source code from the compiled code(.class to .java).
Ex:- DJDecompiler (saperate installation is require).
Q:- Can you generate jsp equivalent servlet outside the server before the jsp is being requested and its web application is deployed?
A:- For this purpose weblogic server has given as weblogic.jspc Tool.
- To work with this tool please make sure
D:\bea\weglogic81\server\lib\weblogic.jar is added in CLASSPATH.
> java weblogic.jspc -compiler javac ABC.jsp
- This tool generateds jsp equivalent servlet but destroys the source code of jsp equivalent servlet.
> java weblogic.jspc -compiler javac -keepgenerated ABC.jsp
- This tool generates jsp equivalent servlet. But doesn't destroy source code of jsp equivalent servlet.
---------
- Every Jsp execution participates in two phases.
1. Translation phase
2. Request Processing phase
- The process of converting Jsp into an equivalent servlet is called Translation Phase.
- Executing this jsp equivalent servlet(_jspService()) and sending response to browser is called Request Processing phase.
-diagram-
- when jsp equivalent servlet compiled code is not available or even though compiled code is available if source code of jsp is modified compare to earlier request then the request coming to jsp will participate first in Translation phase then in Request Processing phase.
- Otherwise the request coming to jsp directly that participates in Request Processing Phase.