This week's book giveaway is in the JavaScript forum.
We're giving away four copies of JavaScript Promises Essentials and have Rami Sarieddine on-line!
See this thread for details.
The moose likes JSP and the fly likes JSP x Servlets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "JSP x Servlets" Watch "JSP x Servlets" New topic
Author

JSP x Servlets

Gustavo Adolpho Bonesso
Ranch Hand

Joined: May 11, 2002
Posts: 103
I�m using servlets instead of JSP pages, because i have a lot of code made im cgi format, using Java in the legace system.
I�m rewriting some programs, but i have some doubts about performance. There�s performance diference between JSP pages and Servlets rendering the page with the same functionality ?
Thank�s


Gustavo Adolpho Bonesso<br />SCJP1.4
Jessica Sant
Sheriff

Joined: Oct 17, 2001
Posts: 4313

Originally posted by Gustavo Adolpho Bonesso:
[is] There�s performance diference between JSP pages and Servlets rendering the page with the same functionality ?

On the first request to the JSP -- you might experience a lag as the application server translates and then compiles the JSP. But subsequent requests will be just as fast as a Servlet. This problem can be overcome by simply pre-compiling the JSPs.
Gustavo Adolpho Bonesso
Ranch Hand

Joined: May 11, 2002
Posts: 103
Thank you, Jessica, and sorry about my english mistake (i speak portuguese, and always change "is there" by "there is", wich is the question form of my born language).
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
If you're really keen to performance tuning, you should remember that even though the JSP gets compiled into a servlet, the JSP compiler usually generates a lot of unnecessary out.println's into the servlet. For example with WebLogic's JSPC compiler, the resulting servlet sources are full of out.println("\r");...


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Gustavo Adolpho Bonesso
Ranch Hand

Joined: May 11, 2002
Posts: 103
Lasse,
Do you know something about the treatment that Websphere give when compile jsp? By the way, do you have any tip about where i can see the compiled servlet ?
Tank you !
Philip Shanks
Ranch Hand

Joined: Oct 15, 2002
Posts: 189
i don't know about WebSphere, but most servlet containers have an intermediate directory where the servlet code is created... this is then comiled into servlet bytecode.
Some servers (like Tomcat, I believe) call this directory "work". The admin interface to the WebSphere server should allow you to set the location of the work directory, or at least see what the default location is.


Philip Shanks, SCJP - Castro Valley, CA
My boss never outsources or has lay-offs, and He's always hiring. I work for Jesus! Prepare your resume!
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
There's a little trick for getting to know where the generated servlet sources are... It's called "put a syntax error in the JSP and see where the error message points". This works at least with WebLogic 6.1 (its compiler refers to a __mypage_jsp.java in a temporary directory called something like .wlnotdelete/foo12345.war/...)
You could try that with WebSphere also. I actually have WebSphere installed in my linux box but I guess it has some "keep-generated" option disabled because I can't find any generated sources.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSP x Servlets