954,568 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Registration Problem using Jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="com.py.db.*, java.sql.*" %>    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="style.css">
<title>Registration</title>
</head>
<body>
<%
    String id = request.getParameter("login_id");
    String password=request.getParameter("password");
    String email= request.getParameter("email");
    DataSource ds = new DataSource();
    ds.executeUpdate("insert into user (login_id, password, email) value ('"+id+"','"+password+"','"+email+"')");
    %>


<table align="center" border="0" width="100%">
<tr><td class="titleheader">    

you are successful registered</td></tr></table>

</body>
</html>


why i cant save my data to database?

Beryl
Newbie Poster
1 post since Apr 2008
Reputation Points: 10
Solved Threads: 0
 

You should get proper smack on hands for attempting to communicate with db through JSP. The correct way to communicate with bd is collect data from form and send them to servlet, you can do validation either on form page with script or on servlet side. Servlet does all communication with db and you then just collect results either data stored/data retrived/some error occured. JSP is just for presentation purpose it is servlet that is the worker.
Please have look on these tutorials from Sun Microsystems

peter_budo
Code tags enforcer
Moderator
15,436 posts since Dec 2004
Reputation Points: 2,806
Solved Threads: 902
 
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="com.py.db.*, java.sql.*" %>    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="style.css">
<title>Registration</title>
</head>
<body>
<%
    String id = request.getParameter("login_id");
    String password=request.getParameter("password");
    String email= request.getParameter("email");
    DataSource ds = new DataSource();
    ds.executeUpdate("insert into user (login_id, password, email) value ('"+id+"','"+password+"','"+email+"')");
    %>


<table align="center" border="0" width="100%">
<tr><td class="titleheader">    

you are successful registered</td></tr></table>

</body>
</html>

why i cant save my data to database?


hi Friend!

I think You forgotton to use s in values ( its VALUES not VALUE)


Correct Code is :
ds.executeUpdate("insert into user (login_id, password, email) values ('"+id+"','"+password+"','"+email+"')");

nazim_virani
Newbie Poster
1 post since Apr 2008
Reputation Points: 10
Solved Threads: 1
 

where had u call database its not visible in ur coding check your connection

sumit_indian
Newbie Poster
10 posts since Jun 2007
Reputation Points: 6
Solved Threads: 1
 

idiot. The answer has already been given and it's not what you say (as usual, you're wrong in everything you say).

jwenting
duckman
Team Colleague
8,392 posts since Nov 2004
Reputation Points: 1,662
Solved Threads: 337
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You