Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

request parameters not available in next jsp page  RSS feed

 
mudassir shahab
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi chaps...

i have designed two jsp pages and one databasebean...
first jsp is front end which suppose to take data from user..another interact with the databasebean to store the information gained through the first bean..the problem is that when i give input it do not store in the database...i am providing u the source code..the browser shows no error..
one more thing: do u know what is :java.sql.SQLException: General error
-----------------------------------------------------------------
(jsp input page)

<%@ page session="true"%>
<html>
<head>
<head>ABC Online Shopping Store Registration</head>
</head>
<body>
<FORM METHOD=POST ACTION="registerdata.jsp">
<TABLE align="center">
<TR>
<TD>Name:</TD>
<TD><INPUT TYPE="text" NAME="name"></TD>
</TR>
<TR>
<TD>Email</TD>
<TD><INPUT TYPE="text" NAME="email"></TD>
</TR>
<TR>
<TD>Login Name:</TD>
<TD><INPUT TYPE="text" NAME="id"></TD>
</TR>
<TR>
<TD>Password</TD>
<TD><INPUT TYPE="password" NAME="pass"></TD>
</TR>
<TR>
<TD></TD>
<TD><INPUT TYPE="submit" value="registration"></TD>
</TR>
</TABLE>
</FORM>
</body>
</html>
-----------------------------------------------------
<jsp:useBean id="user" scope="request" class="cart.register.data.storeBean"/>

<jsp:setProperty name="user" property="name" value="name"/>
<jsp:setProperty name="user" property="email" value="email"/>

<jsp:setProperty name="user" property="id" value="id"/>

<jsp:setProperty name="user" property="password" value="pass"/>

</jsp:useBean >
<jsp:forward page="registerarea.jsp" />
----------------------------------------------------------------
package cart.register.data;
import java.sql.*;
public class storeBean
{
private Connection databaseConnection;
private Statement statement;
private String nam;
private String email;
private String pass;
private String ids;
private ResultSet author;
public storeBean()
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String sourceURL="jdbc dbc nline";
databaseConnection=DriverManager.getConnection(sourceURL);
statement = databaseConnection.createStatement();

// while(author.next())
//{
// (author.getString("id")+" "+ author.getString("name")+" "+ author.getString("fname") );
//}
}
catch(ClassNotFoundException cnfe)
{
System.err.println(cnfe);
}
catch(SQLException sqle)
{
System.err.println(sqle);
}
}
public void setName(String nam)
{ try
{
// String insert = "INSERT INTO cart(name) VALUES ('"+nam+"')";
this.nam=nam;
int stmtInt = statement.executeUpdate("insert into shopper (name) values ('"+nam+"')");
}
catch (Exception e)
{
System.err.print(e);
}
}
public void setEmail(String emails)
{
try
{
// String insert = "INSERT INTO cart (email) VALUES ('"+emails+"')";
this.email=emails;
int stmtInt = statement.executeUpdate("insert into shopper (email) values ('"+email+"')");
}
catch(Exception ew)
{
}
}
public void setId(String id)
{
try
{ // String insert = "INSERT INTO cart (id) VALUES ('"+id+"')";
this.ids=id;
int stmtInt = statement.executeUpdate("insert into shopper (id) values ('"+ids+"')");
}
catch(Exception et)
{
}
}
public String getName()
{
return this.nam;
}
public void setPassword(String pass)
{
try
{
//String insert = "INSERT INTO cart (password) VALUES ('"+pass+"')";
this.pass=pass;
int stmtInt = statement.executeUpdate("insert into shopper (password) values('"+pass+"')");
}
catch(Exception po)
{
}
}
}
 
G Raghavan
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi mudassir,
You are trying to insert the values in the database with every setParameter method. if your database table has fields which does not allow null values then this is going to create problem. instead after setting all the values use just one update query for all the values.
hope this solves ur problem
regards,
Raghavan
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!