Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / June 2006

Tip: Looking for answers? Try searching our database.

How to pass the variables more than 2 jsp

Thread view: 
Ming伯 - 19 Jun 2006 09:32 GMT
Hi!

 I want to write the 3 jsp codes and they will use a common variable
or array.  How can I do to use variable "name" common?

Ming

//
"selectForm.jsp"======================================================

<%@page contentType="text/html"%>
<%@page pageEncoding="Big5"%>
<%@page import = "java.sql.*"%>
<html>
   <head><title></title></head>
   <body>
       <form action="resultForm.jsp" method="post">
       <%
               .
               .
               .
               .

       String sql;
       sql = "SELECT Model from Components where Category = 'Mother
Board'";
       ResultSet rs = smt.executeQuery(sql);

       out.println("<select size='1' name = 'name'>");

       while(rs.next())
           out.println("<option>" + rs.getString(1));
           out.println("</select>");
           con.close();
       %>

       <input type="submit" value="">
       </form>

   </body>
</html>

//
"resultForm.jsp"======================================================

<%@page contentType="text/html"%>
<%@page pageEncoding="Big5"%>
<%@page import = "java.sql.*"%>
<html>
   <head><title></title></head>
   <body>
   <form action="query.jsp" method="post">
   <%
       String Strresult[] = new String[10];
       int i = 0;
               .
               .
               .
               .
       String name =
               new
String(request.getParameter("name").getBytes("ISO-8859-1"));
       String sql = "select Standard from Combinations where Model ='"
+ name + "'";
       String color;
       ResultSet rs = smt.executeQuery(sql);

               .
               .
               .
           con.close();

   %>
       <input type="submit" value="">
       </form>

   </body>
</html>

//
"query.jsp===========================================================
<%@page contentType="text/html"%>
<%@page pageEncoding="Big5"%>

<html>
   <head><title>JSP Page</title></head>
   <body>
     <%
       String name;
       name=request.getParameter("name");

       out.println(":"+name+"<p>");
     %>  
   </body>
</html>
steen - 19 Jun 2006 14:29 GMT
If you just want your code to work, just add a
<input type='hidden' name='name'
value='<%request.getParameter("name")%>' >
to your 2nd jsp page.

/Steen

Ming wrote:
> Hi!
>
[quoted text clipped - 91 lines]
>     </body>
> </html>
Ming伯 - 19 Jun 2006 17:28 GMT
> If you just want your code to work, just add a
> <input type='hidden' name='name'
> value='<%request.getParameter("name")%>' >
> to your 2nd jsp page.
>
> /Steen

Steen,

 Do u mean add the code in resultForm.jsp?  Where can I add the code?
Thx!

Ming


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.