This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

clean jsp

 
liliya woland
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a jsp file where I'm trying to separate html and jsp. I moved most of
html out by now, but I still have pretty big file that contains html
elements that I'd rather move. I know the file can be cleaned up, but don't
know how to do this with the least ammount of extra code. Here is an example of what I'd like to change:

out.println("<tr><td class='plaintext'><b>Project Title:</b></td>");
out.println("<td class='plaintext'>");
if (! request.getParameter("T3").equals("null") )
out.println(request.getParameter("T3"));
out.println("</td></tr>");

out.println("<tr><td class='plaintext'><b>Project #:</b></td>");
out.println("<td class='plaintext'>");
if (! request.getParameter("T4").equals("null") )
out.println(request.getParameter("T4"));
out.println("</td></tr>");

Thanks in advance.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64982
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why on earth would you move HTML out of a JSP? And to where?

Why are you using out.println() statements to emit what should be template text?

I think you are definitely headed in the wrong direction.
 
liliya woland
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, so I got rid of most of out.println, and now I have jsp page in this spirit:
<tr><td class='plaintext'><b>Project NO:</b></td>
<td class='plaintext'>
<% if(request.getParameter("T1") != null )out.println(request.getParameter("T1")); %>
<tr><td class='plaintext'><b>Project Title:</b></td>
<td class='plaintext'>
<% if(request.getParameter("T3") != null) out.println(request.getParameter("T3")); %>
</td></tr>
But it still seams like a dirty code. Can the above be cleaned up a little more?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64982
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. If you are using a JSP 2.0 container, eliminate Java completely from your pages by using the JSTL and EL in lieu of scriplets.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic