• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

return to wrong page

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i am creating my web site using jsp. the problem that is faced is when i click submit button after execute my page, it will return to wrong page. however i already type return to the relevant page in my program. how to make sure that after click submit button, my page will return to the relevant page. my program is using frame. Firstly, i select option from the list bar. after select, it will execute my program. unfortunately after execute it returned to the wrong page
 
Ranch Hand
Posts: 572
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry Can't understand your problem. Please post some code.
you specify action in form tag and clicking on submit it goes to the specified action.
<form action="/myjsp.jsp" method="POST">
//form elements here
</form>
 
jil shi
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<form name="form1" method="post" action="page1.jsp">
<%String propVal = request.getParameter("prop");
out.print(propVal);

if (propVal.equals("klcv")) {
//response.sendRedirect(response.encodeRedirectUrl("klcv_write_online_registration.jsp"));
String server = "localhost";
session.setAttribute("server", server);
String database = propVal;
session.setAttribute("database", database);

Class.forName("org.gjt.mm.mysql.Driver");
DriverManager.registerDriver((Driver) Class.forName("org.gjt.mm.mysql.Driver").newInstance());
String url = ("jdbc:mysql://"+server+"/"+database+"" );
Connection conn = (Connection)DriverManager.getConnection(url,"","");

String sql_1 = "SELECT * FROM smbyer INTO OUTFILE 'klcv_smbyer.txt' "+
"FIELDS TERMINATED BY '|' LINES TERMINATED BY '\r\n' ";
Statement stmt_1 = conn.createStatement();
ResultSet rset_1 = stmt_1.executeQuery(sql_1);
conn.close();

} else if (propVal.equals("sv")) {
//response.sendRedirect(response.encodeRedirectUrl("sv_write_online_registration.jsp"));
String server = "localhost";
session.setAttribute("server", server);
String database = propVal;
session.setAttribute("database", database);

Class.forName("org.gjt.mm.mysql.Driver");
DriverManager.registerDriver((Driver) Class.forName("org.gjt.mm.mysql.Driver").newInstance());
String url = ("jdbc:mysql://"+server+"/"+database+"" );
Connection conn = (Connection)DriverManager.getConnection(url,"","");
String sql_1 = "SELECT * FROM smbyer INTO OUTFILE 'sv_smbyer.txt' "+
"FIELDS TERMINATED BY '|' LINES TERMINATED BY '\r\n' ";
Statement stmt_1 = conn.createStatement();
ResultSet rset_1 = stmt_1.executeQuery(sql_1);
conn.close();

}

String brv= "brv";
session.setAttribute ("database", brv);%>
<h1> </h1>
<h1> </h1>
<META HTTP-EQUIV="refresh" CONTENT="2; URL=page1.jsp">
<h2 align="center"><font color="#000099">Data transfer completed!</font></h2>
</form>
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm still not really clear on what you are trying to do...

I don't see a SUBMIT button anywhere in your form...

All the code looks like it does is query a database based on the value of the request parameter named "prop", but nothing is done with the results of the database query.

The session parameter named "database" gets set to either "klcv" or "sv" depending on the value of the "prop" request parameter, but then it is set to "brv" no matter what at the end of the scriptlet.

Your form, if it ever could be submitted, sends a POST request to page1.jsp, however, you also have a META "refresh" on the page that sends a GET request to page1.jsp after 2 seconds.
 
jil shi
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The submit button is created at other page. Not the same page with the code that i provided. Below are part coding of submit button page:<form name="form1" method="post" action="select_2_property.jsp" onSubmit="return chk();">
<table border="0">
<tr><td><font color="#0929AF"><strong>Online Registration</strong></font></td></tr>
<tr><td>Select Property That You Are Interested</td></tr>
<tr><td>
<select name="prop">
<option value="done" selected="selected">----- Select -----</option-->
<option value="klcv">Kuala Lumpur Cityview</option>
<option value="sv">Sentul View</option>
</select>    
<input class="submit" type="submit" name="submit" value="Submit">
</td></tr>
</table>
</form>
 
Ali Gohar
Ranch Hand
Posts: 572
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi jil shi,
I have used the following tag, its working fine at my side.
<META http-equiv="refresh" content="2; URL=/jsp2.jsp">
 
jil shi
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i knw this code is working fine. when i add list bar to the program, it return to the wrong page. that was the problem
 
reply
    Bookmark Topic Watch Topic
  • New Topic