Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > newbie: JSP vs Servlets

Reply
Thread Tools

newbie: JSP vs Servlets

 
 
Robert Magdziarz
Guest
Posts: n/a
 
      12-29-2006
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/


 
Reply With Quote
 
 
 
 
Robert Klemme
Guest
Posts: n/a
 
      12-29-2006
On 29.12.2006 18:48, Robert Magdziarz wrote:
> 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
 
Reply With Quote
 
 
 
 
=?ISO-8859-1?Q?Arne_Vajh=F8j?=
Guest
Posts: n/a
 
      12-29-2006
Robert Magdziarz wrote:
> 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
 
Reply With Quote
 
Robert Magdziarz
Guest
Posts: n/a
 
      12-29-2006
Does this mean that when I open URL http://localhost/xyz/xyz.jsp the code in
<% %> is run compiled, not interpreted?

Uzytkownik "Arne Vajhøj" <> napisal w wiadomosci
news:45955692$0$49207$...

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



 
Reply With Quote
 
Robert M. Gary
Guest
Posts: n/a
 
      12-29-2006

Robert Magdziarz wrote:
> 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

 
Reply With Quote
 
Mark Rafn
Guest
Posts: n/a
 
      12-29-2006
>Uzytkownik "Arne Vajhøj" <> napisal w wiadomosci
>> JSP pages get compiled to servlets so performance should
>> be the same.


Robert Magdziarz <> wrote:
>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 <http://www.dagon.net/>
 
Reply With Quote
 
=?ISO-8859-1?Q?Arne_Vajh=F8j?=
Guest
Posts: n/a
 
      12-29-2006
Robert Magdziarz wrote:
> Uzytkownik "Arne Vajhøj" <> napisal w wiadomosci
> news:45955692$0$49207$...
>> 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
 
Reply With Quote
 
=?ISO-8859-1?Q?Arne_Vajh=F8j?=
Guest
Posts: n/a
 
      12-29-2006
Robert M. Gary wrote:
> Robert Magdziarz wrote:
>> 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.

>
> 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).


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
 
Reply With Quote
 
R.A.M.
Guest
Posts: n/a
 
      12-30-2006
Is it possible to see source code of the servlet generated?

Uzytkownik "Arne Vajhøj" <> napisal w wiadomosci
news:45956ef0$0$49199$...
> Robert Magdziarz wrote:
>> Uzytkownik "Arne Vajhøj" <> napisal w wiadomosci
>> news:45955692$0$49207$...
>>> 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



 
Reply With Quote
 
Lew
Guest
Posts: n/a
 
      12-30-2006
R.A.M. wrote:
> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[JSP] difference between jsp:forward and jsp:include alexjaquet@gmail.com Java 0 06-02-2006 01:21 PM
Java servlets: Hi All! I want to display xml file in browser using servlets datta.saru Software 0 05-15-2006 03:30 PM
Threading - ASP. Net vs JSP/Servlets Peter Beck ASP .Net 4 11-19-2003 03:28 PM
Java Software JSP/Servlets for Website Template implmentation Prateeksha Web Services Java 0 08-29-2003 07:53 AM
Catching exceptions in JSP when they occur in Servlets Mick Java 0 08-06-2003 01:12 PM



Advertisments