473,397 Members | 2,068 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

JSP conditions

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:

Expand|Select|Wrap|Line Numbers
  1. String gotopage = "";
  2. if(mydata == 1)
  3. {
  4.      gotopage = /"pager.jsp?mymessage=err";
  5. }
  6. else if(mydata == 34
  7. {
  8.    gotopage = /"pager.jsp?mymessage=duper";
  9. }
  10. else
  11. {
  12.     gotopage = /"pager.jsp?mymessage=proc";
  13. }
  14.  
  15.  
  16. RequestDispatcher dispatcher = 
  17.   getServletContext().getRequestDispatcher(gotopage);    
  18. dispatcher.forward(request, response);
  19. ...
JSP

Expand|Select|Wrap|Line Numbers
  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.
Nov 16 '07 #1
1 2670
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:

Expand|Select|Wrap|Line Numbers
  1. String gotopage = "";
  2. if(mydata == 1)
  3. {
  4.      gotopage = /"pager.jsp?mymessage=err";
  5. }
  6. else if(mydata == 34
  7. {
  8.    gotopage = /"pager.jsp?mymessage=duper";
  9. }
  10. else
  11. {
  12.     gotopage = /"pager.jsp?mymessage=proc";
  13. }
  14.  
  15.  
  16. RequestDispatcher dispatcher = 
  17.   getServletContext().getRequestDispatcher(gotopage);    
  18. dispatcher.forward(request, response);
  19. ...
JSP

Expand|Select|Wrap|Line Numbers
  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.
You can straight away assign the message to be displayed to mymessage, instead of giving err or proc.
In the jsp u can display the msg by <%=mymessage%>
Nov 16 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: twins | last post by:
Hi, Iam wondering if there is any method to do the following: 1) When a file is created in a directory in local computer. 2) When the mysql date stored in the DB approaches the current date and...
5
by: GIMME | last post by:
One of my coworkers insists that one should never use static methods because race conditions exist. Thinking along the lines that all variable assignments are assignments to static variables. ...
1
by: Jo | last post by:
I am having a real problem with the Launch conditions in VS .NET and can only come to the conclusion that it is a bug. It states quite emphatically in the MSDN that Launch Conditions WILL be...
5
by: Uday Deo | last post by:
Hi everyone, I am looping through 4 nested loops and I would like to break in the inner most loop on certain condition and get the control on the 2 nd loop instead of 3rd loop. Here is briefly...
6
by: rshepard | last post by:
All my python books and references I find on the web have simplistic examples of the IF conditional. A few also provide examples of multiple conditions that are ANDed; e.g., if cond1: if cond2:...
2
by: Igor | last post by:
1. Are stored procedures WITH ENCRYPTION slower than the ones without encryption? 2. Should i put most restrictive conditions first or last in WHERE? In which order does MSSQL execute...
1
by: ajayvaram | last post by:
<?xml version="1.0" encoding="utf-8"?> <CategoryList> <Category ID="01" Title="One"> </Category> <Category ID="03" Title="Three"> </Category> <Category ID="04" Title="Four"> ...
1
by: mlgmlg | last post by:
Hello, I have a text box (on a Single Form) that I use to color code milestones based on a value. I use the “Conditional Formatting” tool to format four of the conditions, which works great! ...
12
by: =?ISO-8859-1?Q?Ren=E9?= | last post by:
Hi, is there a rule of thumb what is better/faster/more performant in SQL Server 2005? a) SELECT * FROM A INNER JOIN B ON B.ID = A.ID AND B.Cond1 = 1 AND B.Cond2 = 2 b) SELECT * FROM A INNER...
4
by: Prashanth Kumar B R | last post by:
Hi, I have situation in C++ where in I'll have to add around 20-25 conditions <compare a variable against a number> to an if statement. Is there any limit on the number of expressions/conditions...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.