• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how does JSP get transformed to servlet ?

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I read that jsp is transformed to servlet. How does that happen ?

Servelt has code like "public class SomeServlet extends HttpServlet { ..............."
When a jsp is compiled, how does it derive this code ? what name will this servlet get ? I am confused with this. Please explain this mechanism of jsp getting transformed to servelt.

thanks
 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think it is really up to the web container as to the particulars on how the JSP gets translated into Java code. Looking at the generated source from Tomcat, I can tell you that it does not translate a JSP into an HttpServlet class but it does translate it into something similar.

The answers to your questions really depend on the server implementation you are using. For Tomcat you can specifiy a "work" folder in the application context definition that tells the generated code where to go. Tomcat will name the java and class files differently than say, Websphere.
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The process is discussed in this article.
 
Mark Williams
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the link Bear. I am still confused though. Why does everyone say that a JSP gets translated into a servlet? Looking at the generated code, the .java looks similar to a servlet but it doesn't appear to actually implement the HttpServlet interface. (or is it HttpServlet super class? I can't check, I am on my iPhone...)
 
Bear Bibeault
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, it does. The article does not show the entire class.
 
Mark Williams
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:Yes, it does. The article does not show the entire class.



My work computer is forcing me to upgrade Adobe right now so instead of twiddling my thumbs, I got on my laptop and downloaded the source code for Tomcat. I now see that each translated JSP is a class that extends HttpJspBase which extends HttpServlet, which means you are right and I have learned something today. Thanks!
 
Bear Bibeault
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's what the ranch is for!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic