0

I have a jsp in which there is a textbox.

After posting the data I want to do a redirection and then want this textbox to be populated with the string in ADD (plz refer the below code) in page 1, the problem I'm facing is that there is a query in first page which is making this textbox empty.

I heard that I can make use of QueryString() or please suggest me any other process if available, but I'm not sure of how to use it. The redirection code is as below.

<%
try {
    ResultSet rs = null;

    String Add = request.getParameter("Allocation"); // this is the string

    String user = (String) session.getAttribute("myusername");

    Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
    Date d1 = new Date();  

    String d1_str = new SimpleDateFormat("yyyy-MM-dd").format(d1); 

    Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","system","tiger");
    PreparedStatement ps = con.prepareStatement("UPDATE SCOPE1 SET ALLOCATED='"+d1_str+"', SPECIALIST='"+user+"' WHERE DBID='"+Add+"'");
    con.setAutoCommit(true);

    int i = ps.executeUpdate();

    if(i!=1) {
        String s = "Users.jsp?tgt1 = " + Add + ""; // I wanted to know what should go here
        response.sendRedirect(s);
    }
    else {
        out.println("err");
    }
}
catch(Exception e) {
    out.println(e);
}
%>

and the name of my text box is tgt1 in page 1.

Thanks

4

1 回答 1

0

所以你想在 tgt1 文本框中显示字符串,对吧?然后在 User.jsp 中,使用获取字符串String addStr=request.getParameter("tgt1");并将输入文本的值设置为:

<input type=text name=tgt1 value="<%=addStr%>">
于 2012-09-18T14:24:06.323 回答