Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > how to pass the string array from A jsp to B jsp

Reply
Thread Tools

how to pass the string array from A jsp to B jsp

 
 
=?big5?B?TWluZ6dC?=
Guest
Posts: n/a
 
      06-24-2006
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>主機板查詢結果</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("jdbcdbc: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="確認交易">
<input type='hidden' name='name' value='<%= name %>'>
<input type='hidden' name='Test' value='<%= Test %>'>

</form>

</body>
</html>

 
Reply With Quote
 
 
 
 
=?UTF-8?B?RHJhxb5lbiBHZW1pxIc=?=
Guest
Posts: n/a
 
      06-24-2006
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
 
Reply With Quote
 
 
 
 
John O'Conner
Guest
Posts: n/a
 
      06-24-2006
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!



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

--
John O'Conner
 
Reply With Quote
 
Jan Peter Stotz
Guest
Posts: n/a
 
      06-24-2006
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
How to Pass session parameters from one jsp to another jsp sridhar kumar ch Java 1 06-28-2006 05:28 PM
How to Pass session parameters from one jsp to another jsp sridhar kumar ch Java 0 06-28-2006 11:16 AM
Pass XML string from Javascript to JSP dmckeon@ameritas.com Javascript 3 06-15-2006 05:42 PM
[JSP] difference between jsp:forward and jsp:include alexjaquet@gmail.com Java 0 06-02-2006 01:21 PM



Advertisments