• Post Reply Bookmark Topic Watch Topic
  • New Topic

HTML or JSP?

 
Cameron Park
Ranch Hand
Posts: 371
  • Mark post as helpful
  • send pies
  • 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?
 
SoonAnn Lim
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • 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.
 
MIchael Kmiec
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!