• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

HTML or JSP?

 
Ranch Hand
Posts: 371
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I have a question about an example I am studying. The design of the application is that if the processing bean detects that a user is not registerd (from db) then the JSP page that invoked the bean will forward to a register JSP page, which is like this
<html>
<head>
<title>Customer Registration</title>
</head>
<body>
<center><h1>Customer Registration</h1></center>
<hr>
Please register.
<form action="/JSPTechSupport/register.jsp" method="POST">
<table>
<tr>
<td>First Name:</td>
<td><input type="text" name="firstName" size="30"></td>
</tr>
<tr>
<td>Last Name:</td>
<td><input type="text" name="lastName" size="30"></td>
</tr>
<tr>
<td>Phone Number:</td>
<td><input type="text" name="phoneNumber" size="30"></td>
</tr>
</table>
<br><input type="submit" value="Submit Request">
</form>
</body>
</html>
My question is, why is it a JSP and not HTML instead? JSP hes to be translated into a servlet and takes more resources, right?
 
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When you detect an user is a non-registered user, you can forward the user to a register page. Since if you don't include any java code inside this page, you can simply save this file as .html. You need to use the .jsp when you include any java code in the page. If you use the extension .jsp which contain pure html page, it still work but the response is slower than .html page because this page is intepreted by jsp/servlet engine instead of regular webserver. So use .jsp page wisely or you lose the performance. Hope this helps.
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
SoonAnn Lim makes a good point about performance; however most (if not all) JSP implementations are optimized to handle these issues.
Besides, you only lose compile time the first time the JSP is accessed, because then (as with servlets) the classes reside in memory. Granted, you might not want to make *all* your pure HTML documents JSP, but in this case the difference would be negligible.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic