User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JSP section within the Web Development category of DaniWeb, a massive community of 402,860 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,978 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JSP advertiser: Lunarpages JSP Web Hosting
Views: 681 | Replies: 1
Reply
Join Date: Nov 2007
Posts: 22
Reputation: chicago1985 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
chicago1985 chicago1985 is offline Offline
Newbie Poster

Eliminate conditions in JSP

  #1  
Nov 15th, 2007
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

  1. <%
  2. String mymessage = request.getParameter("mymessage")
  3.  
  4. if(mymessage.equals("err"))
  5. {
  6. out.println("Error on the page");
  7. }
  8. else if(mymessage.equals("dup"))
  9. {
  10. out.println("Duplicate issue.");
  11. }
  12. else if(mymessage.equals("proc"))
  13. {
  14. out.println("Process message issue");
  15. }
  16. %>

Please advise.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Aug 2007
Posts: 74
Reputation: lookof2day is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 9
lookof2day lookof2day is offline Offline
Junior Poster in Training

Re: Eliminate conditions in JSP

  #2  
Nov 22nd, 2007
Better option is to upgrade your container or do it in Servlets
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb JSP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the JSP Forum

All times are GMT -4. The time now is 1:14 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC