general questions about jsp

Thread Solved

Join Date: Nov 2007
Posts: 144
Reputation: emilio is an unknown quantity at this point 
Solved Threads: 0
emilio emilio is offline Offline
Junior Poster

general questions about jsp

 
0
  #1
Aug 6th, 2008
i just starter to learn jsp and i have few questions.

1) in my jsp project i have jsp page and java classes that defined as jsp beans.
my jsp page contains submit button. is there a way to define that each time i press the
button the program will run a function from one of the java classes that defined as beans ?

2) is there a command that can make the jsp page to be runned again?
at the end of my jsp page i want to write:

  1. <% if (...) { %>
  2. run the page again
  3. <% } %>

so when i run the page at the end if the if's condition is true the page will be runned again.

3) in my jsp page i have a select form:

  1. <form><SELECT SIZE=1 align="center" name="mode">
  2. <OPTION SELECTED VALUE = "UU"> user vs user </OPTION>
  3. <OPTION VALUE = "UC"> user vs computer </OPTION>
  4. <OPTION VALUE = "CU"> computer vs user </OPTION>
  5. </SELECT></form>

how can i get the string of the current selected option ?
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 8
Reputation: nikhildoomra is an unknown quantity at this point 
Solved Threads: 2
nikhildoomra nikhildoomra is offline Offline
Newbie Poster

Re: general questions about jsp

 
0
  #2
Aug 7th, 2008
hey u can use
response.redirect("this page") to run the page again...

nd for... selecting a string u can retrieve it through javascript...
also u can get value by using... request.getParameter("mode");
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 144
Reputation: emilio is an unknown quantity at this point 
Solved Threads: 0
emilio emilio is offline Offline
Junior Poster

Re: general questions about jsp

 
0
  #3
Aug 7th, 2008
i tryed to get selected option like this:

  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  4. <title>JSP Page</title>
  5. </head>
  6. <body>
  7. <select size="1" name="mode">
  8. <option value="o1">1</option>
  9. <option value="o2">2</option>
  10. <option value="o3">3</option>
  11. </select>
  12.  
  13. <% String s = request.getParameter("mode"); %>
  14. <p><%=s%>
  15. </body>
  16. </html>

it gives me null. what am i doing wrong ?
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 4,217
Reputation: peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of 
Solved Threads: 489
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is offline Offline
Code tags enforcer

Re: general questions about jsp

 
-1
  #4
Aug 7th, 2008
1) None of the drop-down option was declared as default to display
<option value="o2" selected="selected">2</option>
2) You want to run this or something similar in functionality not technology
  1. <% String s = request.getParameter("mode"); %>
  2. <p><%=s%>
when a change was detected on drop-down not immediately after you display it on screen. For such thing JavaScript would be more suitable
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)

LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 144
Reputation: emilio is an unknown quantity at this point 
Solved Threads: 0
emilio emilio is offline Offline
Junior Poster

Re: general questions about jsp

 
0
  #5
Aug 7th, 2008
i tried it like this:
  1. <select size="1" name="mode">
  2. <option value="o1" selected>1</option>
  3. <option value="o2">2</option>
  4. <option value="o3">3</option>
  5. </select>
  6.  
  7. <p><%=(request.getParameter("mode"))%>

i think it's the right syntax when the first option is pre selected. it still doesnot work when i run the page.

i'm not allowed to use javascript only jsp
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 4,217
Reputation: peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of 
Solved Threads: 489
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is offline Offline
Code tags enforcer

Re: general questions about jsp

 
-1
  #6
Aug 7th, 2008
Have look at chap1 from Beginning JSP, JSF and Tomcat Web Development: From Novice to Professional pg11 onwards can be to some interest to you. Source code is available for download too
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)

LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC