Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Pre-compiled JSP?  RSS feed

 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

Someone asked me this question, and I'm not really sure of the answer.

Is it possible to pre-compile the JSP's in a webapp? I tend to think not, since every servlet runner would have it's own way of dealing with JSP's and *where* to put the compiled servlets.

The main reason behind wanting to do this, is that if a company develops a web application, and want to sell it both as a hosted app, and as a self-hosted app, they'd want to prevent the buyer from being able to mess around with the JSPs.

My first suggestion is to make sure there is strictly presentation logic in the JSP, but we all know this is sometimes like the "impossible dream".
 
sridhar satuloori
Ranch Hand
Posts: 144
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes!! it is possible to precomiple the JSP's using command line compiler provided by the webcontainers, i think almost all the webcontainers will provide this facility. and the command line compiler can take the war file as the input and compiles them into java -> class files and puts it in approprite directory for that container. Tomcat has this facility. check for JspC documentation for how to do this.
As you rightly pointed out, it saves the time jsp->java->class creation so, it improves the performance "for the first time".
hope this will help you :-)
Sridhar
 
Sreenivasa Majji
Ranch Hand
Posts: 224
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Most of the JSP engines allows to pre-compile JSP's, but the JSP specifications doesn't mentioned any thing about the naming conventions of the generated servlets. So any two of the JSP generated servlet names may not be the same. I tried in Both Tomcat and Resin and they are different. If you are developing big applications with lots of JSPs then pre-compilation is really helpful.
My $0.02
Originally posted by Mike Curwen:
Hi all,

Someone asked me this question, and I'm not really sure of the answer.

Is it possible to pre-compile the JSP's in a webapp? I tend to think not, since every servlet runner would have it's own way of dealing with JSP's and *where* to put the compiled servlets.

The main reason behind wanting to do this, is that if a company develops a web application, and want to sell it both as a hosted app, and as a self-hosted app, they'd want to prevent the buyer from being able to mess around with the JSPs.

My first suggestion is to make sure there is strictly presentation logic in the JSP, but we all know this is sometimes like the "impossible dream".


------------------
Sreenivasa Kumar Majji
Sun Certified Java Programmer
SCJP Mock Test
 
sridhar satuloori
Ranch Hand
Posts: 144
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To add to this Precompilation has the advantage only for the first access. Also if you change the JSP and container is able to reload the JSP's dynamically then it will compile the JSP once again
Sridhar
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess my main concern is about the spec being silent on *how* a vendor chooses to "make things work".

The WAR file structure does *not* need to be duplicated by a particular servlet container, and in fact many vendors make it differently.

So even if i pre-compiled the JSP's... how to make it a deployable 'package'. If I wanted to sell my app as 'shrink wrapped' software, I'd almost need a different installation procedure for each servlet runner?

Because I *wouldn't* want to distribute JSPs with my app. Only class files.
 
richardtham
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,
Thanks for your valuable comments. I have found some valuable resources which I hope could shed more lights into this. Pls comment more on the following article:
http://www.whizlabs.com/products/scwcd/tips.html
The most popular JSP Architecture is a server side implementation of the popular MVC (Model View Controller) design pattern. Here the Servlet represents the Controller, JSP the view and JavaBean maps to the model. The servlet takes the request from the client (browser), instantiates/creates the JavaBean and forwards the request to the JSP. Finally JSP which represents the view sends back the response to the client.
The major advantage of MVC model is the separation between the presentation and business logic. This clean separation of the presentation from content leads to the delineation of the roles and responsibilities of the developers and web page designers, especially in complex situations. The other advantages includes flexibility, extensibility and reusability.

The goal of Business Delegate object pattern is to minimize the coupling between presentation-tier clients and the business service API, thus hiding the underlying implementation details of the service. In this way we enhance the manageability of the application.

[This message has been edited by richardtham (edited November 08, 2001).]
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!