Total members 10262 | Gratitudes |It is currently Wed May 23, 2012 9:33 pm Login / Join Codemiles


All times are UTC [ DST ]




Post new topic Reply to topic  Quick reply  [ 1 post ] 
Author Code Snippet
 Code subject: use java beans with jsp form
PostPosted: Wed Jan 21, 2009 12:11 am 
Offline
Mastermind
User avatar

Joined: Tue Mar 27, 2007 10:55 pm
Posts: 2279
Location: Earth
Has thanked: 39 time
Have thanks: 61 time

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;
    }
    

_________________
Currenlty programming with : java , html , php , and javascript . (OCJP-6 certified )


TOP
 Profile Send private message  
Reply with quote  
Post new topic Reply to topic Quick reply  [ 1 post ] 
Quick reply


  

 Similar topics
 video chat application in java
 navigating to database using java
 java mobile apps
 need help in java
 Read your gmail using Java code
 Java Programing to communicating port parallel
 Java Chat
 Steganography in java
 java code for listing folder contents from remote folder
 java

All times are UTC [ DST ]


Users browsing similar codes

Users browsing this forum: No registered users and 1 guest



Jump to:  
Previous Code Snippet | Next Code Snippet 




Home
General Talks
Finished Projects
Code Library
Games
Tutorials

Java
C/C++
C-sharp
php
Script
JSP/Servlets
Ajax
ASP/ASP.net
Google SEO
Database
Communications
Phpbb3 styles
Photoshop tutorials
Flash tutorials
Find a job






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team