Thank you very much for the code tip, I'm going to look it today, hopefully
it shouldn't be too much of a problem. Looks like the mailing list cut most
of my JSP out of my last email :(
Thanks again,
Graeme :)
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
>From: Bhushan_Bhangale <[EMAIL PROTECTED]>
>Reply-To: A mailing list about Java Server Pages specification and
>reference <[EMAIL PROTECTED]>
>To: [EMAIL PROTECTED]
>Subject: Re: JSPs/DBs and HTML Forms
>Date: Tue, 16 Apr 2002 09:10:18 +0530
>MIME-Version: 1.0
>Received: from [192.18.99.108] by hotmail.com (3.2) with ESMTP id
>MHotMailBE84EABB007A4004310CC012636CAA3C0; Mon, 15 Apr 2002 20:52:06 -0700
>Received: from swjscmail1 (swjscmail1.Sun.COM [192.18.99.107])by
>swjscmail2.java.sun.com (Postfix) with ESMTPid 1E75D21FBC; Mon, 15 Apr 2002
>21:49:34 -0600 (MDT)
>Received: from JAVA.SUN.COM by JAVA.SUN.COM (LISTSERV-TCP/IP release 1.8d)
>with spool id 1598261 for [EMAIL PROTECTED]; Mon, 15 Apr
>2002 21:48:20 -0600
>Received: from bosvwl01.infy.com (bosvwl01.infy.com [216.52.49.35]) by
> swjscmail1.java.sun.com (Postfix) with SMTP id 4607E4858 for
><[EMAIL PROTECTED]>; Mon, 15 Apr 2002 21:38:20 -0600 (MDT)
>Received: from 192.168.200.82 by bosvwl01.infy.com (InterScan E-Mail
>VirusWall NT); Mon, 15 Apr 2002 23:38:05 -0400
>Received: from punmsg02.ad.infosys.com ([192.168.170.15]) by
>INDHUBBHS02.ad.infosys.com with Microsoft SMTPSVC(5.0.2195.4905);
>Tue, 16 Apr 2002 09:10:18 +0530
>From [EMAIL PROTECTED] Mon, 15 Apr 2002 20:52:53 -0700
>Delivered-To: [EMAIL PROTECTED]
>X-MimeOLE: Produced By Microsoft Exchange V6.0.5762.3
>content-class: urn:content-classes:message
>X-MS-Has-Attach:
>X-MS-TNEF-Correlator:
>Thread-Topic: JSPs/DBs and HTML Forms
>Thread-Index: AcHk0WSpygu/NF3lQSicyk7RdYwBFAAIuYOg
>X-OriginalArrivalTime: 16 Apr 2002 03:40:18.0822 (UTC)
> FILETIME=[6DCC6A60:01C1E4F8]
>Message-ID:
><[EMAIL PROTECTED]>
>Sender: A mailing list about Java Server Pages specification and reference
><[EMAIL PROTECTED]>
>
>Its very simple to write a SQL after getting all the form elements values
>in some variables. You just need to concatenate all the values and need to
>create a INSERT statement. See for example :-
>
>String var1 = request.getParameter("var1);
>String var2 = request.getParameter("var2);
>String var3 = request.getParameter("var3);
>
>String query = "INSERT INTO TABLENAME(VAR1, VAR2, VAR3) VALUES(";
>if (var1 != null && var1.trim().length() != 0)
> query += "'" + var1 "',";
>if (var2 != null && var2.trim().length() != 0)
> query += "'" + var2 "',";
>if (var3 != null && var3.trim().length() != 0)
> query += "'" + var3 "',";
>
>if (query.charAt(query.length() - 1) == ',')
> query = query.substring(0, query.length());
>
>Now your whole query is ready in query variable.
>
>If still have any doubt then you can ask me.
>
>This is just an approach. You can take care of all kinds of types here like
>int, date, etc and instead of String for query use StringBuffer which is
>much more efficient.
>
>-----Original Message-----
>From: Graeme McLaren [mailto:[EMAIL PROTECTED]]
>Sent: Tuesday, April 16, 2002 4:20 AM
>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","www-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
_________________________________________________________________
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