I want to use implicit sending of the HTTP parameter address from the servlet and automatically go to the HTTP page.
How to Use servlet to read parameters and page turns in Web. xml
Import java. Io. ioexception;
Import java. Io. printwriter;
Import java. SQL. connection;
Import java. SQL. drivermanager;
Import java. SQL. preparedstatement;
Import java. SQL. sqlexception;
Import javax. servlet. servletconfig;
Import javax. servlet. servletexception;
Import javax. servlet. http. httpservlet;
Import javax. servlet. http. httpservletrequest;
Import javax. servlet. http. httpservletresponse;
Public class loginv1servlet extends httpservlet {
Private string xmlname, xmlpass;
Protected void doget (httpservletrequest arg0, httpservletresponse arg1)
Throws servletexception, ioexception {
Dopost (arg0, arg1 );
}
Public void Init (servletconfig config) throws servletexception {
// Read the content of the XML document during initialization // This Is A superclass method to override
Xmlname = config. getinitparameter ("name ");
Xmlpass = config. getinitparameter ("pass ");
/*
* <Init-param>
* <Param-Name> pass </param-Name>
* <Param-value> 123456 </param-value>
* Write the statement in the XML file in the <servlet> Block
* </Init-param>
*/
}
Protected void dopost (httpservletrequest req, httpservletresponse res)
Throws servletexception, ioexception {
// First, the data stream encoding on the client solves the Chinese problem.
Req. setcharacterencoding ("gb2312 ");
// Obtain the data transmitted by the customer
String STR = Req. getparameter ("action ");
String id = Req. getparameter ("ID ");
String name = Req. getparameter ("name ");
String amount = Req. getparameter ("amount ");
Res. setcontenttype ("text/html; charset = gb2312 ");
Printwriter PW = res. getwriter ();
PW. println ("<HTML> ");
PW. println ("<title> prepared product information </title> <body> ");
PW. println ("No.:" + id );
PW. println ("name:" + name );
PW. println ("Quantity:" + amount );
If ("1". Equals (STR )){
// Electronic Payment
PW. println ("<a href = 'HTTP: // www.post.com.cn 'target = _ blank> go to online banking </a> ");
} Else {
// Remittance
PW. println ("<a href0000'info.html '> fill in the details </a> ");
}
PW. println ("</body> ");