DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/)
-   JSP (http://www.daniweb.com/forums/forum24.html)
-   -   Eliminate conditions in JSP (http://www.daniweb.com/forums/thread96941.html)

chicago1985 Nov 15th, 2007 8:55 pm
Eliminate conditions in JSP
 
I have a Servlet that checks for information and if there is an issue it forwards the message to presentation page (JSP). Now I want to stop using conditions in scriptlets in the JSP. Please advise how I can do it in this situation in my Tomcat 4.1.27 container. I dont have JSTL or EL due to restrictions in my environment.

Servlet that forwards to JSP:

String gotopage = "";
if(mydata == 1)
{
    gotopage = /"pager.jsp?mymessage=err";
}
else if(mydata == 34
{
  gotopage = /"pager.jsp?mymessage=duper";
}
else
{
    gotopage = /"pager.jsp?mymessage=proc";
}


RequestDispatcher dispatcher =
  getServletContext().getRequestDispatcher(gotopage);       
dispatcher.forward(request, response);
...
JSP

<%
String mymessage = request.getParameter("mymessage")

if(mymessage.equals("err"))
{
    out.println("Error on the page");
}
else if(mymessage.equals("dup"))
{
    out.println("Duplicate issue.");
}
else if(mymessage.equals("proc"))
{
    out.println("Process message issue");
}
%>

Please advise.

lookof2day Nov 22nd, 2007 12:42 pm
Re: Eliminate conditions in JSP
 
Better option is to upgrade your container or do it in Servlets


All times are GMT -4. The time now is 10:33 pm.

Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC