public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
PerformTask(request,response);
}
public void init(ServletConfig config) throws ServletException
{
super.init(config);
/*Add your code here */
//初始化ServletSessionPoolManager的环境变量.
try
{
Environment environment = new Environment();
//Gets an initial context:得到一个初始的上下文关系.
Context context = environment.getInitialContext();
b_mgr = (ServletSessionPoolManager)context.lookup("bea.jolt.pool.SessionPoolManager");
return;
}
catch(NamingException namingexception)
{
throw new ServletException(namingexception.toString());
}
}
public void PerformTask(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
{
res.setContentType(CONTENT_TYPE);
ServletSessionPool servletsessionpool = (ServletSessionPool) b_mgr.getSessionPool("webjoltpool");
if (servletsessionpool == null)
{
System.out.println("Fail to look up session pool !");
return;
}
//调用Tuxedo服务:
//如果有入参请在这里对参数赋值:
String as[] = req.getParameterValues("SVCNAME");
String svrname = (String) as[0];
System.out.println(svrname);
ServletResult servletresult;
try
{
/*call 方法调用说明:
call(String, HttpServletRequest). Method in class bea.jolt.pool.servlet.ServletSessionPool
Invokes a BEA TUXEDO service without an explicit transaction.
call(String, HttpServletRequest, Transaction). Method in class bea.jolt.pool.servlet.ServletSessionPool
Invokes a BEA TUXEDO service.
参数说明: Input parameters for the BEA TUXEDO service are passed to this method
as a javax.servlet.http.HttpServletRequest object request.
The names of the members in request must match the names of
the BEA TUXEDO service parameters.
For input parameters, member names are the names of the HTML form field.
Any members with names that do not match the BEA TUXEDO service parameter names
are ignored. If no trancation is null.
*/
servletresult = servletsessionpool.call(as[0], req, null);
}
catch (SessionPoolException sessionpoolexception)
{
System.out.println("Your request cannot be completed at this moment.\n Diagnostic Message is: " + sessionpoolexception.getMessage());
return;
}
catch (ServiceException serviceexception)
{
System.out.println("Service exception,Error message:" + serviceexception.getMessage());
return;
}
catch (ApplicationException applicationexception)
{
ServletResult servletresult1 = (ServletResult) applicationexception.getResult();
System.out.println("Application error \n Application code is " + servletresult1.getApplicationCode());
return;
}
catch (Exception exception)
{
System.out.println("Unexpected exception Exception is " + exception);
return;
}
if (svrname.equalsIgnoreCase("WEB114"))
{
/***************查询业务类型**********************
* ---011 网上单位中文名称查询 *
* ---012 网上单位英文名称查询 *
* ---113 网址类别查询 *
************************************************/
System.out.println("reqtype is "+req.getParameter("REQTYPE"));
char querytype = req.getParameter("REQTYPE").charAt(0);
System.out.println("querytype: "+querytype);
String jspName="";
Vector vc = new Vector();
int i=0;
int count=0; /* 返回记录的条数 */
switch (querytype)
{
case '0' : /*网上关键字查询*/
{
count = servletresult.getCount("CODE");
System.out.println("servlet 0: "+count);
for (i=0;i<count;i++)
{
Vector vcin = new Vector();
vcin.removeAllElements();
vcin.addElement((String) servletresult.getStringValue("NAME", i, ""));
vcin.addElement((String) servletresult.getStringValue("CODE", i, ""));
vcin.addElement((String) servletresult.getStringValue("ADDR", i, ""));
vcin.addElement((String) servletresult.getStringValue("ADDR_CODE", i, ""));
vcin.addElement((String) servletresult.getStringValue("TEL", i, ""));
vcin.addElement((String) servletresult.getStringValue("ENGLISH_NAME", i, ""));
vcin.addElement((String) servletresult.getStringValue("ENGLISH_CODE", i, ""));
vc.addElement(vcin);
}
jspName="/wellhopeweb/web/114/webKey.jsp";
break;
}
case '1' : /*网上分类查询*/
{
count = servletresult.getCount("ID");
System.out.println("servlet 1: "+count);
for (i=0;i<count;i++)
{
Vector vcin = new Vector();
vcin.removeAllElements();
vcin.addElement((String) servletresult.getStringValue("ID", i, ""));
vcin.addElement((String) servletresult.getStringValue("NO", i, ""));
vcin.addElement((String) servletresult.getStringValue("NAME", i, ""));
vcin.addElement((String) servletresult.getStringValue("PROPERTY", i, ""));
vc.addElement(vcin);
}
jspName="/wellhopeweb/web/114/webClass.jsp";
break;
}
default :
{
System.out.println("No this query type!");
}
}
req.setAttribute("RESULTSET", (Vector) vc);
rd = getServletContext().getRequestDispatcher(jspName);
rd.forward(req, res);
}
}
}