I really suggest buying a book to learn JSP, that's the way I learnt and
is really the best way. I can recommend Beginning JSP Web Development by
Wrox Press -
http://www.amazon.com/exec/obidos/ASIN/1861002092/qid=1018940667/sr=8-1/
ref=sr_8_71_1/102-7390197-2280917 Its really made step by step and shows
you all the import points, including setting up databases etc...

Regards,
Peter Dolukhanov

-----Original Message-----
From: A mailing list about Java Server Pages specification and reference
[mailto:[EMAIL PROTECTED]] On Behalf Of Graeme McLaren
Sent: 15 April 2002 23:50
To: [EMAIL PROTECTED]
Subject: JSPs/DBs and HTML Forms

Hi everyone, I'm completely new to JSPs and I'm finding a somewhat
daunting
area.  Specifically I'm having a problem inserting information from an
html
form to a database using a JSP.

Basically I've got the problem of getting the parameter and the value
from
the form then inserting it in to the database with SQL.

I can use  mystring=request.getParameter("TheNameOfTheFormInput");  to
get
the value from the form elements.  Once I've done this I'm completely
lost
as to how to write the SQL to insert the values from the form elements
INTO
the database.

Can anyone guide me through this, point me in the right direction or
give me
any tips at all.  Any advice would be greatly appreciated.

Thank you in advance,

Graeme :)

P.S. Currently I've got a JSP like this:

<!-- imports the JDBC functions -->
<%@ page import="java.sql.*" %>
<html>
<head>
<title>JDBC Example</title>
</head>
<body>
<h1>JDBC with JSP</h1>
<%
/* various variable declarations */
Connection dbc;
Statement st;
String sql;
ResultSet rs;
ResultSetMetaData rsmd;

try {
  /* load JDBC driver for PostgreSQL database */
  Class.forName("postgresql.Driver");

  /* make a connection to the database */

dbc=DriverManager.getConnection("jdbc:postgresql://localhost/webtest","w
ww-d
ata","");

  /* create and execute a statement */
  st=dbc.createStatement();
  sql=("SELECT * FROM example");
  st.executeQuery(sql);

  /* get the results and metadata */
  rs=st.getResultSet();
  rsmd=rs.getMetaData();

  /* how many columns are there? */
  int numcols=rsmd.getColumnCount();

  /* start table and print headings */
  out.println("<table>\n<thead>\n<tr>");
  int i;
  for (i=1;i<=numcols;i++)
    out.print("<th>"+rsmd.getColumnLabel(i)+"</th>");
  out.println("</tr>\n</thead>\n<tbody>");

  /* print the rows of the table */
  while (rs.next()) {
    out.print("<tr>");
    for (i=1;i<=numcols;i++)
      out.print("<td>"+rs.getObject(i)+"</td>");
    out.print("</tr>");
    }

  /* end table and close DB */
  out.print("</tbody>\n</table>\n");
  dbc.close();

  /* error handling */
  } catch (Exception e) {
    out.println("<p>Error in JDBC database access</p>");
    out.println("<p>"+e+"</p>");
  } ;

%>
</body>
</html>

Thanks again,

G :)

Public Sub House()

On Error Resume drink

         If PintGlass.empty = True Then
                 PintGlass.refill
   Else
                 PintGlass.drink
         End if

stomach.add PintGlass

MsgBox " I've had .... " & stomach.count & " Pints"
MsgBox "VERY DRUNK"

End Sub


_________________________________________________________________
Join the world's largest e-mail service with MSN Hotmail.
http://www.hotmail.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://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.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://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com

Reply via email to