GeeCON Prague 2014*
The moose likes Beginning Java and the fly likes dynamic help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "dynamic help" Watch "dynamic help" New topic
Author

dynamic help

rich werth
Ranch Hand

Joined: Sep 21, 2001
Posts: 57
ok i have a drop down populated by oracle when the page loads using jsp. now i want to be able to select items in both lists and dynamicly build a query that will populate a table built on the results. I have the dynamic table. i don't have the dynamic query or how it will be submitted once the submit button is pressed. i'm thinking a javaBean to access session variables but i'm not sure. can anyone help me or shoot me?
Sandra Sharpe
Greenhorn

Joined: Jan 29, 2001
Posts: 7
If the user has selected an option from your drop down box and submits the web page, their selection is available via the javax.servlet.ServletRequest or similarly the javax.servlet.http.HttpServletRequest object.
If you are using .jsp or servlet you can access this via the command.... request.getParameter("parameter_name_here") or if a user can select multiple options from the drop down you could use request.getParameterValues("parameter_name_here");
Once you have the values, you can pass these values into a supporting java class that can query the database based upon the results. For Example : select * from employee where emp_name = value_user_selected. My company uses Oracle Stored procedures and parameters into stored procedures.
I hope this helps....

rich werth
Ranch Hand

Joined: Sep 21, 2001
Posts: 57
this is my code to fill a drop down
<select name="loc">
<%<br /> int i=0;<br /> while (rs.next()) {<br /> i++;<br /> String location = rs.getString(1);<br /> %>
<option value=<%= i %>><%= location %>
<% } %>
</select>
this is the default query i run on the page so it doesn't load blank
<%<br /> String queryStr3 = "Select * from NON_IT where REQUESTOR_NAME = 'jane user'";<br /> ResultSet eresults = dept.executeQuery(queryStr3);<br /> %>
i would like to know how to build a dynamic query from what the user selects in the drop list and have that populate the same page with the new results when the user presses the submit button. can someone help me?
 
GeeCON Prague 2014
 
subject: dynamic help