JSP Post Data Viewer : Basics « JSP « Java






JSP Post Data Viewer

/*
<%@page contentType="text/html"%>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<jsp:useBean id="userB" class="com.java2s.UserBean" >
    <jsp:setProperty name="userB" property="*" />
</jsp:useBean>
<html>
<head><title>Post Data Viewer</title></head>
<body>
<h2>Here is your posted data</h2>

    <strong>User name</strong>: 
  <c:out value="${userB.username}" /><br><br>
   <strong>Department</strong>: 
  <c:out value="${userB.department}" /><br><br>
   <strong>Email</strong>: 
  <c:out value="${userB.email}" />

</body>
</html>
*/
package com.java2s;

public class UserBean implements java.io.Serializable{

String username;
String email;
String department;

public UserBean(){}

public void setUsername(String _username){

    if(_username != null && _username.length() > 0)
        username = _username;
    else
         username = "Unknown";
}

public String getUsername(){

    if(username != null)
        return username;
    else
        return "Unknown"; }

public void setEmail(String _email){

     if(_email != null && _email.length() > 0)
        email = _email;
    else
         email = "Unknown";
}

public String getEmail(){

   if(email != null)
        return email;
    else
        return "Unknown";
}

public void setDepartment(String _department){

     if(_department != null && _department.length() > 0)
        department = _department;
    else
         department = "Unknown";
}

public String getDepartment(){
    
   if(department != null)
         return department;
    else
        return "Unknown"; 
    }

}
           
       








Related examples in the same category

1.JSP Passing Parameters
2.Simplest Jsp page: A Web Page
3.Output: Creating a Greeting
4.Simple JSP outputSimple JSP output
5.Simple JSP page to display the random number
6.Comments in JSP page
7.Declaration Tag Example
8.Declaration Tag - Methods
9.Expression Language Examples
10.Passing parameters
11.JSP Initialization
12.Welcome page and top level URL
13.JSP Expression Language
14.JSP without beans
15.Request header display in a JSP
16.Multiple Declaration
17.Embedding Code
18.pwd -- print working directory
19.JSP post
20.JSP in J2EE
21.JSP Performance
22.JSP Best Practices and Tools
23.JSP Model 2JSP Model 2
24.JSP: expression language 2JSP: expression language 2
25.JSP Basics: Dynamic Page Creation for Data Presentation 2JSP Basics: Dynamic Page Creation for Data Presentation 2
26.JSP Directives: your page
27.JSP Directives
28.JSP Basics ch02 JSP Basics ch02
29.JSP Basics: Generalized Templating and Server Scripting 1JSP Basics: Generalized Templating and Server Scripting 1
30.JSP Basics: Generalized Templating and Server Scripting 2JSP Basics: Generalized Templating and Server Scripting 2
31.JSP Basics: Generalized Templating and Server Scripting 3JSP Basics: Generalized Templating and Server Scripting 3
32.CSS, JavaScript, VBScript, and JSP 1CSS, JavaScript, VBScript, and JSP 1
33.CSS, JavaScript, VBScript, and JSP 2CSS, JavaScript, VBScript, and JSP 2
34.Advanced Dynamic Web Content Generation. 1Advanced Dynamic Web Content Generation. 1