Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

JSP redirecting pages and DROP DOWN boxes

Posted on 2003-03-26
5
Medium Priority
?
403 Views
Last Modified: 2010-04-01
How do you redirect a JSP page. My example is when you go from one page to another a simple JSP page processes your information but i don't want to stay on that page. I want to process and move on the page i want to redirect too.



Also, I'm learning JSP and want to use some drop down boxes. Does anyone have any examples of how to work with Drop Down boxes and JSP. I need to query the database and add the info from the database into the dropdown box and don't know where to start.
0
Comment
Question by:TSK
5 Comments
 
LVL 18

Accepted Solution

by:
bobbit31 earned 80 total points
ID: 8211664
// process the information
...

// redirect to another page
<% response.sendRedirect("http://yourserver.com/newpage.jsp"); %>

second part:

<select name=mySelect>
<%
Class.forName("<your database driver>").newInstance();
Connection con = DriverManager.getConnection("<connection string to your db>");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("select field1 from tbl");

while (rs.next()) {
%>
<option value="<%= rs.getString("field1") %>"><%= rs.getString("field1") %>
<%
}
rs.close();
stmt.close();
con.close();
%>

</select>

0
 
LVL 14

Expert Comment

by:kennethxu
ID: 8212852
bobbit show you how to redirect browser to a new page, this will be a separate request. you can also forward current request on to another jsp page:
<jsp:forward page="another.jsp" />
0
 

Author Comment

by:TSK
ID: 8213799
How do use a bean in this example of the JSP document?

Class.forName("org.gjt.mm.mysql.Driver").newInstance();
       try
       {
            String us, pass, memberID;
            boolean doneheading = false;
           
            dbconn = DriverManager.getConnection("jdbc:mysql://localhost/nutrition","saundersk","kevin");
            username = request.getParameter("username").trim().toUpperCase();
            password = request.getParameter("password").trim().toUpperCase();
           
            sql = dbconn.prepareStatement("SELECT * FROM member WHERE UPPER(user_name) = ? AND UPPER(password1) = ?");
           
            sql.setString(1, request.getParameter("username"));
            sql.setString(2, request.getParameter("password"));
           
            memberID = results.getString("member_id");
            jsp:getProperty name="mybean" property="memberID scope="session"
           
            results = sql.executeQuery();
0
 
LVL 1

Expert Comment

by:victorli
ID: 8215003
Hi TSK,

It seems you are trying to ask another question which is different from your original one.

Generally if other people have answered your question correctly, you should reward points and clear the question before asking new questions.

0
 
LVL 14

Expert Comment

by:kennethxu
ID: 8215008
agree with victorli.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How do you create a user-centered user experience on your website? And what are some things you should consider in the process?
If you need to complete a Physical to Virtual (P2V), Virtual to Virtual (V2V) conversion to a VMware product (VMware Workstation, Player or VMware vSphere (ESXi) ) for FREE, then there is some good news...
Screencast - Getting to Know the Pipeline
How can you see what you are working on when you want to see it while you to save a copy? Add a "Save As" icon to the Quick Access Toolbar, or QAT. That way, when you save a copy of a query, form, report, or other object you are modifying, you…
Suggested Courses

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question