Deploying Precompiled JSPs on iPlanet

Hi, I would like to deploy the JSPs as pre-compiled class files. I unsuccessfully tried to deploy the generated class files as servlets. Steps followed were: 1) Pre-compile the JSPs into java files using Jasper. 2) Compile the java files to class files. 3) Map the JSP name (for e.g. test.jsp) to the corresponding .class file (i.e. _test_jsp.class) I get a NullPointerException when I access the JSP (and its not in my code). Anybody run into similar problems ? I am using a iPlanet webserver on a unix platform. I would appreciate if someone could give me some pointers on how to go about to do this. Specific details about iPlanet webserver will be great. Thanks Ashwin.

[This message has been edited by Ashwin Desai (edited October 01, 2001).] [This message has been edited by Ashwin Desai (edited October 01, 2001).]

I have been wondering about this for some time.. Is there any advantage in manually precompiling a JSP versus just registering it as a servlet in web.xml, and setting it to load on server startup. For example: I tried this, and it works fine. The server automatically compiles and loads the JSP file as a servlet when it starts. So what is the benefit of going through the trouble of manually compiling the JSP? Please respond. Regards, -Miftah

Ashwin Desai
Ranch Hand

Joined: Jul 17, 2000
Posts: 124

posted Oct 01, 2001 20:36:00

0

Hi, There could be a lot of reasons, but the following two affect my decision. 1) Licensing issues prevent distributing the javac compiler with software. Thus, jsps cannot be evaluated on the fly. 2) You do not want to give out your code i.e. jsp files. Thus, just give compiled versions. Ashwin. [This message has been edited by Ashwin Desai (edited October 01, 2001).]

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944

posted Oct 01, 2001 20:47:00

0

Aaah, never thought of it from a vendor's perspective. Thank you Ashwin. Regards, -Miftah

Um, why would you need to distribute the compiler? If you are selling software written in JSP, well, your customers need a JSP/Servlet engine to deploy on, right? Every Servlet engine that I am aware of is distributed with an appropriate compiler and automatically compiles the JSPs you provide according to your XML deployment descriptors... In fact, I'm relatively certain that this is a REQUIREMENT of the JSP/Servlet specification. So, why worry about distribution of the compiler? [This message has been edited by Dave Soto (edited October 01, 2001).]

Two responses, Ashwin: 1: Another iPlanet user! Write to MooseSaloon@javaranch.com and help lobby for a dedicated iPlanet forum! They have WebLogic and WebSphere, but not iPlanet, and heck if we don't need a little help! 2: JSPs (on iPlanet at least..) are expected to be packaged as jsp.APPS.<webapp name>. There's some additional factors involved, but suffice to say precompiling your JSPs isn't a particularly good idea. If you really need to have something precompiled, servlets and good ole java classes are the best option. If all of your 'real' logic is there, and the JSP is just presentation (as it should be), then viewing the JSPs won't cause any proprietary 'secrets' to be lost, just the API for using the data/logic classes. Hope this helps! BTW, if you adhere to the MVC design pattern, the best way to develop is write your data/logic classes as regular java, write a front-end to accept posts and parameters as a servlet that calls the data/logic classes as appropriate, take the results and add them to the request via the setAttribute() call on the HttpServletRequest, then finally forward the request to a JSP for display. If you're still worried about the JSP, you can write precompiled JavaBeans and/or custom tags for manipulating your presentation without others viewing it. I don't both with that, though. I use the following method to do forwarding, where templateName is the name of the JSP file: <pre> public void forwardToJSP( HttpServletRequest req, HttpServletResponse res, String templateName ) throws ServletException, IOException { // select the JSP templateRequestDispatcher disp; disp = getServletContext().getRequestDispatcher( "/" + templateName ); // forward the request to the template disp.include(req, res);