Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > JSP Basics
|
JSP Basics Beginning-level questions on JSP. More advanced coders should post to Pro JSP.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the JSP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 4th, 2007, 10:42 AM
Authorized User
 
Join Date: Jul 2006
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default Sending JSP form data to web server

Hello guys,

I would like to get user input data from a JSP form in netbeans and send it to a web server but don't know how to do so? anyone have any ideas how this could be done?

Thanks in advance.
Wambozi.

 
Old July 7th, 2007, 02:35 AM
Registered User
 
Join Date: Jun 2007
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to winsonkkp
Default

In try1.jsp file, the coding is

<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<!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=gb2312">
<title>Untitled Document</title>
</head>

<body>
<form action="insertData.jsp" method="post" name="frm1">
Please fill in the blanks and press submit button.
  <br>
  <br>
First Name: <input name="txtFirstName" type="text"><br><br>

Last Name: <input name="txtLastName" type="text"><br><br>

Email: <input name="txtEmail" type="text"><br>
<br>
<input name="btnSubmit" type="submit" value="Submit">
</form>
</body>
</html>


Then in insertData.jsp file, the coding is

<%@ page language = "java" import = "abc.def.*" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>Untitled Document</title>
</head>

<body>
<%
    //contoh Example = new contoh();

    String strFirstName = request.getParameter("txtFirstName");
    String strLastName = request.getParameter("txtLastName");
    String strEmail = request.getParameter("txtEmail");


    //Example.setFirstName(strFirstName);
    //Example.setLastName(strLastName);
    //Example.setEmail(strEmail);
%>
The first name is <%= //Example.getFirstName() %><br>
The last name is <%= //Example.getLastName() %><br>
The email is <%= //Example.getEmail() %><br>
<%
    //Example.insertData();
    //Example.setFirstName(a);
    //Example.setLastName(b);
    //Example.setEmail(c);
%>
ABC <%= //Example.getEmail() %>
</body>
</html>


Don't bother about all the object's method, it all refer to other .java file. But this is work to get form data. And of course this will not run, unless you can the your own .java file.

I hope this can help u...:)

Hello





Similar Threads
Thread Thread Starter Forum Replies Last Post
The best way to design a data entry web form cesemj ASP.NET 2.0 Basics 2 November 5th, 2007 02:44 PM
Sending a web form as parameter see07 ASP.NET 1.x and 2.0 Application Design 7 March 22nd, 2005 07:07 PM
Embedding Office Web Components form JSP sunildath_019 JSP Basics 0 March 17th, 2004 06:11 AM
Embedding Office Web Components form JSP sunildath_019 Pro JSP 0 March 17th, 2004 06:10 AM
import data from web form Mitch Access VBA 8 September 4th, 2003 04:26 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.