Sorry, but i've a code like this (follow), what´s wrong?
<HTML>
<HEAD>
<TITLE>
teste
</TITLE>
</HEAD>
<BODY>
<H1>
Registo
<FORM>
<BR><b>Username</b><INPUT TYPE="text" NAME="username"><BR>
<BR><b>Password</b><INPUT TYPE="password" NAME="password"><BR>
<BR>
<INPUT TYPE="SUBMIT" NAME="Submit" VALUE="Submit">
<INPUT TYPE="RESET" VALUE="Reset">
<% String userName = request.getParameter("username");
String passWord = request.getParameter("password");
//Carrega o driver para jdbc
Class.forName("sun.jdbc.odbc.odbc.JdbcOdbcDriver");
dbconn =DriverManeger.getConnection("jdbc:odbc:myodbc:minhadb");
// Depois da ligação faz o insert
if (dbconn != null) {
PreparedStatement ps=connection.createPreparedStatement(
"insert into users (username, password) values (?,?)");
ps.setString(1, userName);
ps.setString(2, password);
ps.execute();
jsp:forward page="Jspregistosucesso.jsp";
} else { // Otherwise, report the connection error
jsp:forward page="Jspregistofalhou.jsp" ;
}
%>
</FORM>
</H1>
</BODY>
</HTML>
-----Original Message-----
From: A mailing list about Java Server Pages specification and reference
[mailto:[EMAIL PROTECTED]]On Behalf Of Joseph Ottinger
Sent: quarta-feira, 14 de Fevereiro de 2001 11:40
To: [EMAIL PROTECTED]
Subject: Re: JSP/mysql
Too many possibilities to accurately document in a single email, really.
For example:
<%
String userName=request.getParameter("username");
String password=request.getParameter("password");
// ... establish db connection
PreparedStatement ps=connection.createPreparedStatement(
"insert into users (username, password) values (?,?)");
ps.setString(1, userName);
ps.setString(2, password);
ps.execute();
%>
Or you could use taglibraries to do much the same... or EJBs, even, if
you're running a recent enough version of mysql.
But that leaves the more important question behind: why are you trying to do
this? If you're trying to register users, there are better ways; if you're
trying to authenticate users, there are *far* better ways. Rather than seen
implementation details, try to figure out why your architecture has
implementation-level roadblocks first.
Of course, there's always the possibility you don't know your architecture,
and if that's the case, I'd suggest investigation of best practices first.
>From: Paulo Chitas <[EMAIL PROTECTED]>
>Reply-To: A mailing list about Java Server Pages specification and
> reference <[EMAIL PROTECTED]>
>To: [EMAIL PROTECTED]
>Subject: JSP/mysql
>Date: Wed, 14 Feb 2001 11:16:45 -0000
>
>Hello!
>How can i read a username and password from one jsp page and store it in an
>mysql database?
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets