aspose file tools*
The moose likes JSP and the fly likes clean jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "clean jsp" Watch "clean jsp" New topic
Author

clean jsp

liliya woland
Ranch Hand

Joined: Apr 11, 2006
Posts: 134
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

Joined: Jan 10, 2002
Posts: 61661
    
  67

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
liliya woland
Ranch Hand

Joined: Apr 11, 2006
Posts: 134
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

Joined: Jan 10, 2002
Posts: 61661
    
  67

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.
 
Consider Paul's rocket mass heater.
 
subject: clean jsp