Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / December 2006

Tip: Looking for answers? Try searching our database.

newbie: JSP vs Servlets

Thread view: 
Robert Magdziarz - 29 Dec 2006 17:48 GMT
Hello,
I have just started learning Java. I have one question: how about
performance of JSP comparing to Servlets? I am using Windows XP and Debian.
/RAM/
Robert Klemme - 29 Dec 2006 17:55 GMT
> Hello,
> I have just started learning Java. I have one question: how about
> performance of JSP comparing to Servlets? I am using Windows XP and Debian.

JSPs are usually compiled into Servlets, so apart from the initial
compilation hit and a bit of added bookkeeping code there is no
difference.  If you observe a difference then I'd say it's usually
caused by what the Servlet / JSP does - but not attributable to the
mechanism.

Regards

    robert
Arne Vajhøj - 29 Dec 2006 17:55 GMT
> I have just started learning Java. I have one question: how about
> performance of JSP comparing to Servlets? I am using Windows XP and Debian.

JSP pages get compiled to servlets so performance should
be the same.

Good or bad performance depends on what you do in them.

Arne
Robert Magdziarz - 29 Dec 2006 18:03 GMT
Does this mean that when I open URL http://localhost/xyz/xyz.jsp the code in
<% %> is run compiled, not interpreted?

> JSP pages get compiled to servlets so performance should
> be the same.
Mark Rafn - 29 Dec 2006 19:11 GMT
>Uzytkownik "Arne Vajhøj" <arne@vajhoej.dk> napisal w wiadomosci
>> JSP pages get compiled to servlets so performance should
>> be the same.

>Does this mean that when I open URL http://localhost/xyz/xyz.jsp the code in
><% %> is run compiled, not interpreted?

Yes.  The JSP container generates Servlet bytecode (sometimes directly,
sometimes by generating java source and compiling it, and sometimes at
build-time rather than on the first request to the server) from the jsp text.

For most servlet containers, this means the first request of a jsp that hasn't
already been compiled can take quite a bit longer than subsequent requests.  A
lot of sytems have the option to precompile your JSPs to avoid this behavior,
but you then lose the ability to edit and see changes without rebuilding and
redeploying.
--
Mark Rafn    dagon@dagon.net    <http://www.dagon.net/>
Arne Vajhøj - 29 Dec 2006 19:39 GMT
>> JSP pages get compiled to servlets so performance should
>> be the same.
>
> Does this mean that when I open URL http://localhost/xyz/xyz.jsp the code in
> <% %> is run compiled, not interpreted?

Not only compiled - tripple compiled !!

First the JSP compiler translates the JSP page to Java source (servlet).

Then the Java compiler translates that Java source to Java byte code.

And when run the JIT compiler translates the Java byte code to
native instructions.

Arne
R.A.M. - 30 Dec 2006 08:40 GMT
Is it possible to see source code of the servlet generated?

>>> JSP pages get compiled to servlets so performance should
>>> be the same.
[quoted text clipped - 12 lines]
>
> Arne
Lew - 30 Dec 2006 14:49 GMT
> Is it possible to see source code of the servlet generated [from the JSP]?

Yes. There is a directory in the servlet container installation that contains
the JSPs translated to Jav source. The exact directory location depends on the
container installation. For instance, when I use Netbeans to run JSPs the
generated Java code for the JSPs in an application "sesstest" appears in

~/.netbeans/5.5/apache-tomcat-5.5.17_base/work/Catalina/localhost/sesstest/org/apache/jsp/
 .

- Lew
Arne Vajhøj - 30 Dec 2006 15:28 GMT
>>>> JSP pages get compiled to servlets so performance should
>>>> be the same.
[quoted text clipped - 9 lines]
>> native instructions.
> Is it possible to see source code of the servlet generated?

Yes. At least usually.

If you are using a stanldone Tomcat then look in:

<Tomcat root>/work/Catalina/<hostname>/<webapp name>/org/apache/jsp

In JBoss with Tomcat it is:

<JBoss root>/server/<config>\work\jboss.web\<hostname>\<webapp
name>\org\apache\jsp

In WAS I belive that you need to set a configuration parameter
to get it to keep the Java source.

Arne
Robert M. Gary - 29 Dec 2006 18:17 GMT
> Hello,
> I have just started learning Java. I have one question: how about
> performance of JSP comparing to Servlets? I am using Windows XP and Debian.
> /RAM/

For me the difference is complexity. If I'm doing something simple I'll
use JSP. However, I don't want to write pages and pages of JSP code
because it gets unmanageable. Also, if you are using embedded frames
<iframe> and are using different MIME types (gif, etc) you need to use
servlets. I have pages I've written that produce a series of dynamic
jfreechart gifs in iframes. I don't think you can do that is JSP.
The problem with using JSP is that there are no good editors for both
the html and the jsp. I use Eclipse to write the jsp and FrontPage to
mange the HTML (apply style sheets etc). So I find myself bouncing
between the two applications against the same file (gotta be careful).

-Robert
Arne Vajhøj - 29 Dec 2006 19:45 GMT
>> Hello,
>> I have just started learning Java. I have one question: how about
[quoted text clipped - 10 lines]
> mange the HTML (apply style sheets etc). So I find myself bouncing
> between the two applications against the same file (gotta be careful).

JSP's can not generate binary stuff.

But the main choice should be based on:
   mostly tags => JSP
   mostly Java code => servlet + other Java classes
not on complexity.

Arne


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.