Typically, when you deploy an application, WebLogic Server tries to precompile the JSPs of your application.
But why ? How is it sensed to work normally ? What does this mechanism offer ?
That's what I'm going to explain in this article.
How did it work before ?
Well the original schema is the following : you typically deploy your application to your application server.
Once it's deployed, the first user that accesses a JSP has to wait a little bit, the time the JSP got compiled (transformed into a servlet).
As you can see, there is a small problem here : the fact that the JSP is compiled when a user accesses it.
It implies that some users may have to experience a delay when requesting a page, that's not exactly the idea of a good quality of service ...
That's this issue the precompilation was designed to address.
How do I setup precompilation ?
Nowadays, almost all application servers use precompilation.
As written above, precompilation is a way to prevent first users from compiling pages and then wait for them to show up.
You may use precompilation before or during a deployment.
You've got several ways to do so :
Using the weblogic.appc tool (pre-deployment compilation)
One good practice is to take the precompilation step and remove it from the deployment process.
When I say remove, it doesn't mean that we're going to suppress it, but rather than we will reorder the process.
Note : You could also use weblogic.jspc but it's deprecated.
Execute the appc tool like :
You'll see that the size of the WAR has changed (initially 2k)
If we take a closer look at the content of the WAR, we see a new directory and a new file :
As you can see, a new object "__index.class" has been created in the jsp_servlet directory, under WEB-INF\classes.
Note : When using Workshop, you may precompile your JSP by just checking a box :
Using the default mechanism : weblogic.xml (during deployment)
The default behavior is to not compile JSPs. If you want to turn that feature on, you'll have to specify it in your DD weblogic.xml.
<?xml version="1.0" encoding="UTF-8"?>
Using the JSPClassServlet
You may also declare a servlet in your application that will take care of that task.
But the main con is the fact that you have to modify your application by adding extra components. To me, it's not a best practice.
But if you're interested in doing that : http://edocs.bea.com/wls/docs100/webapp/reference.html#wp73711
What's the difference when I precompile myself the JSP or when I let WebLogic do it ?
First of all, the deployment time :)
As the step of precompiling is doing prior to the deployment process, the latter is obviously shortened.
Second, in your directory tree, the location of your JSP won't be the same according to who does the precompilation job.
If you do it manually, compiled JSP will be located in the WEB-INF\classes directory of your WAR, as shown in the example with "weblogic.appc".
If you let WebLogic do it, it will be located (default) in the following tree (outside of the WAR), in the directory DOMAIN_HOME\servers\yourServer\tmp\_WL_user :
Or you may configure this directory by changing the attribute 'working-dir' in your weblogic.xml DD.