olá galera,
ja programo em java a algum tempo e nunca fiz um jsp, hj preciso fazer um para gravar informações num banco de dados e achei q seria facil por ja conhecer java mas estou com dificuldade tem alguem ai q ja tenha felto isso ? estou mysql
grato.
Mas qual seria sua maior dificuldade??
Vc ta usando servlet para acessar o banco??
nao estou usando servlet nao, estou tentando fazer u7m jsp q ja faz isso mas tenho dificuldde como faço para criar o arquivo jsp no Netbeans?
estou meio perdido pra começar
grato
Acho que pra vc seria o ideal fazer uma jsp acessar uma servlet que por sua vez uma outra classe que faça a persistencia que vc precisa…falando em arquitetura seria o ideal…mas cada caso é um caso.
A e aqui no guj tem otimos tutoriais para jsp…
olá galera consegui fazer a conecxao com o banco de dados mais aogra oq eu nao tenho a minima ideia de como fazer e pro jsp pegar os dados da pagina para inserir no banco? como seria eu faço um pagina html e nela chamo o jsp ?
grato.
olá galera pq esse codigo nao da erro mas tb nao insere no banco
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>Cadastro - Bad Evil </title>
</head>
<body>
<form method="post" action="" style="width: 452px" class="style1">
<label id="Label1"> <br />
<fieldset name="Group1" style="height: 126px">
<legend>
<div style="position: absolute; width: 100px; height: 21px; z-index: 1; left: 122px; top: 73px" id="layer2">
Login:</div>
Criar Conta:</legend>
<label id="Label1"> <div style="position: absolute; width: 200px; height: 20px; z-index: 2; top: 107px; left: 230px" id="layer6">
<input name="password" type="password" style="width: 200px" /></div>
<div style="position: absolute; width: 200px; height: 20px; z-index: 2; top: 73px; left: 230px" id="layer5">
<input name="login" type="text" style="width: 200px" /></div>
<br />
<br />
<div style="position: absolute; width: 100px; height: 21px; z-index: 1; left: 122px; top: 109px; bottom: 662px" id="layer3">
Password:</div>
<div style="position: absolute; width: 100px; height: 21px; z-index: 1; left: 122px; top: 145px" id="layer4">
E-mail:</div>
<div style="position: absolute; width: 200px; height: 20px; z-index: 2; top: 142px; left: 230px" id="layer7">
<input name="email" type="text" style="width: 200px" /></div>
</label></fieldset> <input name="ok" type="submit" value="Cadastrar" />
<input name="limpar" type="reset" value="Limpar" /><label id="Label2"><br />
</label> </label> <label id="Label3"> </label></form>
</body>
</html>
<%@page import="java.sql.*"%>
<%
String nome = request.getParameter( "login" );
String senha = request.getParameter( "password" );
String email = request.getParameter( "email" );
Driver d = (Driver)Class.forName("com.mysql.jdbc.Driver").newInstance();
String URL = "jdbc:mysql://localhost:3307/bad_bad";
Connection con = DriverManager.getConnection(URL, "root", "123");
String sql = "INSERT INTO tb_login (login,password,vitorias,email) VALUES (?,?,?,?)";
try
{
PreparedStatement ps = con.prepareStatement(sql);
ps.setString(1,nome);
ps.setString(2,senha);
ps.setInt(3,0);
ps.setString(4,email);
out.println(nome);
ps.executeUpdate();
ps.close();
}
catch(Exception e)
{
e.printStackTrace();
}
finally
{
try
{
if (con != null)
{
con.close();
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
%>