Js|servlet The following code fragment demonstrates a servlet that illustrates (instantiates) a bean and initializes it with the form data sent by the browser. The bean is then added to the request, which is sent to the JSP page (bean1.jsp), which is obtained through the request and processed further.
public void DoPost (HttpServletRequest request,
HttpServletResponse response) {
try {
Govi. Formbean f = new Govi. Formbean ();
String id = request.getparameter ("id");
F.setname (Request.getparameter ("name"));
F.setaddr (Request.getparameter ("addr"));
F.setage (Request.getparameter ("Age"));
Use the ID to compute
Additional Bean properties like info
Maybe perform a DB query, etc.
// . . .
F.setpersonalizationinfo (info);
Request.setattribute ("Fbean", f);
Getservletconfig (). Getservletcontext (). Getrequestdispatcher
("/jsp/bean1.jsp"). Forward (request, response);
catch (Exception ex) {
. . .
}
}
When it is first executed from the default request range of the Usebean operation, that is, the Fbean can be processed in the bean1.jsp of the JSP file.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service