Total members 11895 |It is currently Sun Dec 22, 2024 6:31 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





use Java beans with jsp(Java server Pages) form , here i have three code snippets , one for form and one for after submit form and one for java Bean class.

1. HTML Jsp form
Code:
<html>
    
    <
title>Codemiles :JSP Form with Java Beans </title>
    <
body>
        
        <
form action="afterindex.jsp" >
            
             
  <
p>First name: <input type="text" name="firstName" size=30>
  <
br>Last name: <input type="text" name="lastName" size=30>
  <
br>Email: <input type="text" name="email" size=30>

  <
p><input type="submit" name="Submit">
        </
form>
    </
body>
</
html>

 


2. After submit
Code:
<%@ page import="codemiles.Userentry"%>
<%@ 
page import="codemiles.Userentry"%>
<
jsp:useBean id="EntryBean" class="codemiles.Userentry" type="Userentry" scope="application" />
<
jsp:setProperty name="EntryBean" property="*"/>

<
html>
    
    <
body>
        <
b>
            
Your data has been submitted 
        
</b>
    </
body>
</
html


3. The Java Bean class :
Code:

 

package codemiles
;

/**
 *
 * @author codemiles Team
 */
public class Userentry {
    
String firstName;
    
String lastName;
    
String email;

    public 
void setEmail(String email) {
        
this.email email;
        
System.out.println(email);
    }

    public 
void setFirstName(String firstName) {
        
this.firstName firstName;
        
System.out.println(firstName);
    }

    public 
void setLastName(String lastName) {
        
this.lastName lastName;
        
System.out.println(lastName);
    }

    public 
String getEmail() {
        return 
email;
    }

    public 
String getFirstName() {
        return 
firstName;
    }

    public 
String getLastName() {
        return 
lastName;
    }
    




_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : use java beans with jsp form
 use of Java Beans in jsp     -  
 cmp entity beans     -  
 php login form (sign-in form)     -  
 Please help me in the form field     -  
 Feedback Form in php     -  
 Seconds Form to ( hh:mm:ss) (C++)     -  
 Get Form Numeric value     -  
 Upload Form     -  
 JSF Radio Buttons Form     -  
 FeedBack form Spam     -  



Topic Tags

Servlets/JSP
cron





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com