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:

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

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:

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

how can i get the string of the current selected option ?

Recommended Answers

All 5 Replies

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");

i tryed to get selected option like this:

        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
        <select size="1" name="mode">
            <option value="o1">1</option>
            <option value="o2">2</option>
            <option value="o3">3</option>
        <% String s = request.getParameter("mode"); %>

it gives me null. what am i doing wrong ?

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

<% String s = request.getParameter("mode"); %>

when a change was detected on drop-down not immediately after you display it on screen. For such thing JavaScript would be more suitable

i tried it like this:

<select size="1" name="mode">
            <option value="o1" selected>1</option>
            <option value="o2">2</option>
            <option value="o3">3</option>

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.