Here is an example :
index.jsp
---------------------
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<jsp:useBean id="us" scope="request" class="msgbean.User"></jsp:useBean>
<%
if (request.getParameter("Name") != null) {
//out.write(request.getParameter("Name"));
us.setName(request.getParameter("Name"));
us.setEmail(request.getParameter("Email"));
}
%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<form method="post">
<table>
<tr><td>Name:</td><td><input type="text" name="Name"/></td></tr>
<tr><td>Email:</td><td><input type="text" name="Email"/></td></tr>
<tr><td><input type="submit" value="Submit"/></td></tr>
</table>
</form>
You entered:<br />
Name: <%= us.getName()%></br>
Email: <%= us.getEmail()%></br>
</body>
</html>
----------------------------------
User.java
------------------
package mypak;
public class User {
private String name;
private String email;
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name the name to set
*/
public void setName(String name) {
this.name = name;
}
/**
* @return the email
*/
public String getEmail() {
return email;
}
/**
* @param email the email to set
*/
public void setEmail(String email) {
this.email = email;
}
}
A blog about web application development mainly on backend side
Subscribe to:
Post Comments (Atom)
What is DaemonSet in Kubernetes
A DaemonSet is a type of controller object that ensures that a specific pod runs on each node in the cluster. DaemonSets are useful for dep...
-
Cross-platform compatibility: MAUI allows developers to write code that can run on multiple platforms with minimal modifications. Shared cod...
-
Both .NET and NodeJS are popular programming frameworks that have their own strengths and weaknesses, which makes for an interesting compar...
-
A DaemonSet is a type of controller object that ensures that a specific pod runs on each node in the cluster. DaemonSets are useful for dep...
No comments:
Post a Comment