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