java is a programming language, Servlets and jsps are web technologies built for J2EE (framework|methodology|platform). Tomcat is a popular servlet container used for building web based applications.
As you can imagine, outputting a whole html page to a browser like that is a big hassle: you have to put quotes around all the html and you have to add a "\n" to output the html on a newline.
Instead a SERVLET can use a JSP page to display the html. A JSP page looks like a normal html page--except that it has a few lines of JAVA in it, for instance:
<html> <head> <title>My html page</title> </head> <body> <% String firstname = request.getParameter("firstName"); %> <div><%= firstname %></div> </body> </html> [ October 11, 2006: Message edited by: sven studde ]
A few points to help you get the most out of JavaRanch as a resource:
1) Please modify your display name to mixed case. The all-uppercase can be construed as "shouting" and may considered rude by some. Our eyes will thank you.
2) "Pls" is not a real word. Please take the time to use real words in your posts such as "please".
P.S. I'll save my "scriplets are so yesterday" speech for another time.
I'd like to hear it. Mixing java with html has made me uneasy from the start. This is a discussion forum. Don't be afraid to discuss. Maybe a few alcoholic beverages will loosen those lips. [ October 11, 2006: Message edited by: sven studde ]
I'd like to hear it. Mixing java with html has made me uneasy from the start. This is a discussion forum. Don't be afraid to discuss. Maybe a few alcoholic beverages will loosen those lips.
Stick around and you'll hear it; loud and often. No drinks needed.
If you'd like to hear Bear's opinions in long form, he's had several articles published in our Javaranch Journal. You can find links at top of the JSP forum. They're worth reading.
Cameron Wallace McKenzie
,
author and cow tipper
staff
One thing to note, that throws a wrench into everything, is that at deployment time, there really isn't any difference between Servlets, JSPs and for that matter, Java.
JSPs are simply designed and developed differently from Servlets. However, when JSPs run on the server, the server turns the JSP into a Servlet, and runs the JSP with all of the semantics associated with Servlets running in the web container. You can actually instruct a J2EE application server to save the code that is generated when a JSP is converted into a Servlet at runtime.
With WebSphere, (I'm not sure about the other implementations), it is actually a Servlet running on the server that turns JSP files into Servlets. I alway refer to it as the "BorgServlet", although the name IBM uses is much less creative.
Cheers!
-Cameron McKenzie
Post by:autobot
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
a bit of art, as a gift, the permaculture playing cards