日期:2014-05-18  浏览次数:20634 次

HttpServletRequest 的参数传递问题, 进来看看, 给我解决问题的同时你也能增长一些知识
大家好!   感谢进来帮我解决问题!

问题陈述:
      我在使用CA认证遇上一个问题,   由于CA认证的时候要和CA服务器有一个交互.
而且CA服务器限定WEB程序的客户端不能直接和CA服务器交互,   只能有WEB服务端进行交互.所以CA发出验证信息必须通过web服务器做一个中转.
      在WEB客户端发出验证的时候(通过访问CA服务器的一个地址,   比如说   http://aaa:8080/a.asp),   我是在WEB服务器段做了一个转发的请求(也就是把http://aaa:8080/a.asp先通过web服务器,   在有web服务器转发出去,   具体看后面的代码),   但是客户端发出请求的时候是带有参数的,   我通过我的方法导致CA服务器那边的参数获取不到.
    请大家指点;

代码:
就是把原来请求CA服务器的连接先指向WEB服务器的一个连接

/**
  *   处理ceb验证跳转
  *   pack,   unpack,   stamp,   print
  *   @param   pMapping
  *   @param   pForm
  *   @param   pRequest
  *   @param   pResponse
  *   @return
  *   @throws   OAException
  */
public   ActionForward   dealValidateForward(ActionMapping   pMapping,
ActionForm   pForm,   HttpServletRequest   pRequest,
HttpServletResponse   pResponse)   throws   OAException{
String   operValidate   =   pRequest.getParameter( "operValidate ");
String   cebServerPath   =   CEBValidateConstant.property.getProperty( "cebServerPath ");
String   validatePage   =   " ";
boolean   doOutput   =   true;   //是否需要印章服务器返回数据
if(operValidate.equals( "packValidate ")){
validatePage   =   cebServerPath   +   CEBValidateConstant.property.getProperty( "packValidateURL ");
}else   if(operValidate.equals( "unPackValidate ")){
validatePage   =   cebServerPath   +   CEBValidateConstant.property.getProperty( "unpackValidateURL ");
}else   if(operValidate.equals( "stampValidate ")){
validatePage   =   cebServerPath   +   CEBValidateConstant.property.getProperty( "stampValidateURL ");
}else{
validatePage   =   cebServerPath   +   CEBValidateConstant.property.getProperty( "printValidateURL ");
}
try   {
CEBValidateConstant.invokeRemote(validatePage,   doOutput,   pRequest,
pResponse);
}   catch   (Exception   e)   {
e.getMessage();
throw   new   OAException( "印章校验出错! ");
}
return   null;
}

下面的方法是转发数据包,   和获取返回的数据
/**
  *   访问印章服务器
  *   @param   url   要访问的地址
  *   @param   doOutput   是否需要印章服务器返回信息
  *   @param   request   HttpServletRequest请求包
  *   @param   response   HttpServletResponse响应包
  *   @return   string   被访问的服务器的返回信息
  *   @throws   IOException   如果连接印章服务器失败则抛出IOException
  *   @throws   MalformedURLException  
  */
public   static   String   invokeRemote(String   url,boolean   doOutput,HttpServletRequest   request,HttpServletResponse   response)   throws   IOException,MalformedURLException{
String   retVal   =   null;
ByteArrayOutputStream   baos   =   new   ByteArrayOutputStream();

URL   server   =   new   URL(url);
HttpURLConnection   con