wood burning stoves 2.0*
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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: 60817
    
  65

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: 60817
    
  65

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: clean jsp
 
Similar Threads
Servlet becomming slow
Servlet becomming slow
JSP Help Regarding the Radio Button
Problem in inserting data into access database through jsp file
Problem in inserting data into access database through jsp file