943,816 Members | Top Members by Rank

Ad:
  • JSP Discussion Thread
  • Marked Solved
  • Views: 1009
  • JSP RSS
Aug 6th, 2008
0

general questions about jsp

Expand Post »
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:

jsp Syntax (Toggle Plain Text)
  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:

jsp Syntax (Toggle Plain Text)
  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 ?
Similar Threads
Reputation Points: 20
Solved Threads: 0
Junior Poster
emilio is offline Offline
162 posts
since Nov 2007
Aug 7th, 2008
0

Re: general questions about jsp

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");
Reputation Points: 10
Solved Threads: 2
Newbie Poster
nikhildoomra is offline Offline
8 posts
since Aug 2008
Aug 7th, 2008
0

Re: general questions about jsp

i tryed to get selected option like this:

jsp Syntax (Toggle Plain Text)
  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 ?
Reputation Points: 20
Solved Threads: 0
Junior Poster
emilio is offline Offline
162 posts
since Nov 2007
Aug 7th, 2008
-1

Re: general questions about jsp

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
JSP Syntax (Toggle Plain Text)
  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
Moderator
Featured Poster
Reputation Points: 2786
Solved Threads: 873
Code tags enforcer
peter_budo is offline Offline
6,656 posts
since Dec 2004
Aug 7th, 2008
0

Re: general questions about jsp

i tried it like this:
jsp Syntax (Toggle Plain Text)
  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
Reputation Points: 20
Solved Threads: 0
Junior Poster
emilio is offline Offline
162 posts
since Nov 2007
Aug 7th, 2008
-1

Re: general questions about jsp

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
Moderator
Featured Poster
Reputation Points: 2786
Solved Threads: 873
Code tags enforcer
peter_budo is offline Offline
6,656 posts
since Dec 2004

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JSP Forum Timeline: updating daily news in a webpage
Next Thread in JSP Forum Timeline: error while forwarding page





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC