81,122
社区成员




<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<format action="TestServlet">
w3c在线教程:
<input type="text" name="weburl" size="100"/><br/>
<input type="submit" value="提交"/>
</format>
</body>
</html>
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class TestServlet extends HttpServlet {
private static final long serialVersionUID=-1575386983723846021L;
public void service(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String weburl=request.getParameter("weburl");
System.out.print(weburl);
if(weburl!=null && weburl.equals("http://www.w3csschool.com"))
{
request.setAttribute("weburl", "你输入的是W3C在线教程网");
}
else
{
request.setAttribute("weburl", "你输入的网址在数据库中未有记录");
}
RequestDispatcher dispatcher=request.getRequestDispatcher("result.jsp");
dispatcher.forward(request, response);
}
}
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<servlet>
<description>This is the description of my J2EE component</description>
<display-name>This is the display name of my J2EE component</display-name>
<servlet-name>TestServlet</servlet-name>
<servlet-class>TestServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>TestServlet</servlet-name>
<url-pattern>/servlet/TestServlet</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>结果是:</title>
</head>
<body>
<%=request.getAttribute("weburl")%>
</body>
</html>
<%@page pageEncoding="utf-8" contentType="text/html;charset=utf-8" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">d
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
servlet页面:
response.setContentType("text/html;charset=UTF-8");
response.setCharacterEncoding("UTF-8");
private static final long serialVersionUID=-1575386983723846021L;
public void service(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
//String merchID=request.getParameter("MerchID");
//if(merchID!=null)
//{
// request.setAttribute("merchID", "你输入的是W3C在线教程网");
//}
//else
//{
// request.setAttribute("merchID", "你输入的网址在数据库中未有记录");
//}
//RequestDispatcher dispatcher=request.getRequestDispatcher("result.jsp");
//dispatcher.forward(request, response);
try
{
//String merchid=request.getParameter("MerchID");
//String msgid=request.getParameter("MsgID");
//String cardno=request.getParameter("CardID");
//System.out.println(merchid);
//RequestDispatcher dispatcher=request.getRequestDispatcher("result.jsp");
//dispatcher.forward(request, response);
String cardno="6228480030976274";
String certino="410711199002251";
String name="王*峰";
String phone="13918315*";
String limitdate="";
String cvn2="";
String msgid=getCurrentDateTime();
String merchid="33350018";
String certitype="01";
String cerPwd="1234567890";
String deskey="6350105e40013e7de0530b14640a74e2";
String url="http://101.254.166.186/certification/check";
int conntimeout=50000;
int sotimeout=60000;
CertiRequest req=new CertiRequest();
req.setMerchid(merchid);
req.setMsgid(msgid);
req.setCardno(cardno);
req.setCertitype(certitype);
req.setCertino(certino);
req.setName(name);
req.setPhone(phone);
req.setLimitdate(limitdate);
req.setCvn2(cvn2);
req.setDeskey(deskey);
req.setConntimeout(conntimeout);
req.setSotimeout(sotimeout);
req.setUrl(url);
RequestService serv=new RequestService();
CertiResponse resp;
try
{
resp=serv.send(req);
}
catch(Exception e)
{
e.printStackTrace();
return;
}
System.out.println("返回数据:"+resp.toString());
}
catch(Exception e)
{
e.printStackTrace();
}
}
public static String getCurrentDateTime()
{
SimpleDateFormat dateFormat=new SimpleDateFormat("yyyyddHHmmss");
return String.valueOf(dateFormat.format(new Date()));
}
public static String productFigure()
{
Random rnd=new Random();
int num=rnd.nextInt();
if(num<=0 || num>999999)
{
return productFigure();
}
return String.valueOf(num);
}
2015/09/23 19:04 263,965 commons-codec-1.9.jar
2015/09/23 18:19 305,001 commons-httpclient-3.1.jar
2015/09/23 19:03 62,050 commons-logging-1.1.3.jar
2015/01/13 10:14 313,898 dom4j-1.6.1.jar
2015/01/11 13:45 489,884 log4j-1.2.17.jar
2015/10/10 11:33 23,573 payCheck-1.0.1.jar