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 string array from A jsp to B jsp

Thread view: 
Ming伯 - 24 Jun 2006 02:22 GMT
Hi!

 Do anyone know pass the string array from A jsp to B jsp?  For
example, I want to pass Strresult to query.jsp for operation.  How can
I do?  THX!

Ming

<%@page contentType="text/html"%>
<%@page pageEncoding="Big5"%>
<%@page import = "java.sql.*"%>
<html>
   <head><title>?D???O?d?????G</title></head>
   <body>
   <form action="query.jsp" method="post">
   <%
       String Strresult[] = new String[10];
       String Test = "";
       int i = 0;
       Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
       Connection con =
               DriverManager.getConnection("jdbc:odbc:MT450");
       Statement smt =  con.createStatement();
       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);

       while(rs.next()){
           Strresult[i]=rs.getString(1);
            out.println(Strresult[i++]+"<p>");

           }
           con.close();
   %>
       <input type="submit" value="?T?{????">
    <input type='hidden' name='name' value='<%= name %>'>
    <input type='hidden' name='Test' value='<%= Test %>'>

       </form>

   </body>
</html>
Dražen Gemić - 24 Jun 2006 14:33 GMT
Ming wrote:
> Hi!
>
>   Do anyone know pass the string array from A jsp to B jsp?  For
> example, I want to pass Strresult to query.jsp for operation.  How can
> I do?  THX!

Most obvious method is using session. In your example it does not
look like you are submitting anything important, or any user
input, so, it does not seem that first jsp should submit
data to second. If that is the true, then you can use the
request object and, add attribute to it (request.setAttribute()), and
let the first jsp to forward (jsp:forward) request to second (chaining).

DG
John O'Conner - 24 Jun 2006 16:49 GMT
> Hi!
>
>   Do anyone know pass the string array from A jsp to B jsp?  For
> example, I want to pass Strresult to query.jsp for operation.  How can
> I do?  THX!

What keeps you from sending it the same way that you send "name" or "Test"?

--
John O'Conner
Jan Peter Stotz - 24 Jun 2006 16:59 GMT
Ming伯 schrieb:

>         String name =
>                 new
> String(request.getParameter("name").getBytes("ISO-8859-1"));
>         String sql = "select Standard from Combinations where Model ='"
> + name + "'";

I would suggest reading one or two articles about "SQL-Injection-attacks"
and how to prevent them (hint: PreparedStatement).

Jan


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.