📄 intramartconnectservlet.java
字号:
}
// 僒乕價僗僾儘僷僥傿僴儞僪儔偺愝掕
setServicePropertyHandler(
getServiceManager().getServicePropertyHandler());
// 僙僢僔儑儞儅僱乕僕儍偺愝掕
try {
setSessionManager(SessionManager.getSessionManager());
} catch (SessionManagerException e) {
throw new ServletException(e.getMessage(), e);
}
// 僙僢僔儑儞僾儘僷僥傿僴儞僪儔偺愝掕
setSessionPropertyHandler(
getSessionManager().getSessionPropertyHandler());
// URL僞僀僾偺愝掕
String urlType = servletConfig.getInitParameter(PARAM_REFERER_FORMAT);
setReferrerFormatShort(false);
if (urlType != null && urlType.equalsIgnoreCase("short")) {
setReferrerFormatShort(true);
}
}
/**
* GET儊僜僢僪偵懳墳偟傑偡丅
* 徻嵶偼{@link #execute(HttpServletRequest, HttpServletResponse)}傪嶲徠偟偰偔偩偝偄丅
*
* @param request 儕僋僄僗僩
* @param response 儗僗億儞僗
* @throws ServletException 僒乕僽儗僢僩椺奜偑敪惗
* @throws IOException 擖弌椡椺奜偑敪惗
*/
protected void doGet(
HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
execute(request, response);
}
/**
* POST儊僜僢僪偵懳墳偟傑偡丅
* 徻嵶偼{@link #execute(HttpServletRequest, HttpServletResponse)}傪嶲徠偟偰偔偩偝偄丅
*
* @param request 儕僋僄僗僩
* @param response 儗僗億儞僗
* @throws ServletException 僒乕僽儗僢僩椺奜偑敪惗
* @throws IOException 擖弌椡椺奜偑敪惗
*/
protected void doPost(
HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
execute(request, response);
}
/**
* intra-mart儀乕僗儌僕儏乕儖偺儊僯儏乕偐傜偺儕僋僄僗僩傪庴偗晅偗傑偡丅
* 儁乕僕堷悢偵埲壓偺忣曬傪娷傔傞昁梫偑偁傝傑偡丅<BR>
* application=<I><傾僾儕働乕僔儑儞俬俢></I>,service=<I><僒乕價僗俬俢></I>
*
* @param request 儕僋僄僗僩
* @param response 儗僗億儞僗
* @throws ServletException 僒乕僽儗僢僩椺奜偑敪惗
* @throws IOException 擖弌椡椺奜偑敪惗
*/
protected void execute(
HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
String loginUserIDKey = null;
String loginUserID = null;
String loginGroupIDKey = null;
String loginGroupID = null;
String errorPage = null;
String application = null;
String service = null;
// 傾僾儕働乕僔儑儞ID偲僒乕價僗ID偺庢摼
IntramartConnectUtil.RequestInfo requestInfo =
IntramartConnectUtil.getRequestInfo(request, response);
application = requestInfo.getApplication();
service = requestInfo.getService();
// 儘僌僀儞儐乕僓ID傪庢摼
try {
loginUserIDKey = getSessionPropertyHandler().getLoginUserIDKey();
} catch (SessionPropertyException e) {
throw new ServletException(e.getMessage(), e);
}
loginUserID = request.getParameter(PARAM_LOGIN_USER_ID);
if (loginUserID == null || loginUserID.equals("")) {
// 儘僌僀儞儐乕僓偑愝掕偝傟偰偄側偄応崌丄僙僢僔儑儞僄儔乕儁乕僕偵慗堏
try {
errorPage =
getSessionPropertyHandler().getSessionErrorPagePath();
} catch (SessionPropertyException e) {
throw new ServletException(e.getMessage(), e);
}
request.getRequestDispatcher(errorPage).forward(request, response);
return;
}
// 儘僌僀儞僌儖乕僾ID傪庢摼
try {
loginGroupIDKey = getSessionPropertyHandler().getLoginGroupIDKey();
} catch (Exception e) {
throw new ServletException(e.getMessage(), e);
}
loginGroupID = request.getParameter(PARAM_LOGIN_GROUP_ID);
if (loginGroupID == null || loginGroupID.equals("")) {
// 儘僌僀儞僌儖乕僾偑愝掕偝傟偰偄側偄応崌丄僙僢僔儑儞僄儔乕儁乕僕偵慗堏
try {
errorPage =
getSessionPropertyHandler().getSessionErrorPagePath();
} catch (SessionPropertyException e) {
throw new ServletException(e.getMessage(), e);
}
request.getRequestDispatcher(errorPage).forward(request, response);
return;
}
// 僙僢僔儑儞僆僽僕僃僋僩傪儕僋僄僗僩傪傕偲偵庢摼丒惗惉偡傞
boolean sessionCreated =
IntramartConnectUtil.configSession(
request,
response,
loginUserIDKey,
loginUserID,
loginGroupIDKey,
loginGroupID,
isReferrerFormatShort());
if (!sessionCreated) {
// 僙僢僔儑儞偺惗惉偵幐攕偟偨応崌壗傕偟側偄偱廔椆
return;
}
// 僒乕價僗僒乕僽儗僢僩偵慗堏
String serviceServletPath = null;
try {
serviceServletPath = this.serviceHandler.getServiceServletPath();
} catch (Exception e) {
throw new ServletException(e.getMessage(), e);
}
SessionFactory sessionFactory = this.sessionManager.getSessionFactory();
String url = request.getContextPath() + serviceServletPath;
if (sessionFactory == null) {
url = response.encodeURL(url);
} else {
// Version 3.2 屳姺梡
if (sessionFactory.isEncodeRequired()) {
try {
url = sessionFactory.encodeURL(request, response, url);
} catch (Exception e) {
throw new ServletException(e.getMessage(), e);
}
} else {
try {
url += "&"
+ this.sessionHandler.getSessionParameter()
+ "="
+ URLEncoder.encode(
this
.sessionManager
.getSessionObject(request)
.getSessionID());
} catch (Exception e) {
throw new ServletException(e.getMessage(), e);
}
}
}
String applicationParamName = null;
try {
applicationParamName =
this.serviceHandler.getApplicationParamName();
} catch (Exception e) {
throw new ServletException(e.getMessage(), e);
}
String serviceParamName = null;
try {
serviceParamName = this.serviceHandler.getServiceParamName();
} catch (Exception e) {
throw new ServletException(e.getMessage(), e);
}
String encode = null;
try {
encode = getServicePropertyHandler().getClientEncoding();
} catch (ServicePropertyException e) {
throw new ServletException(e);
}
response.setContentType("text/html; charset=" + encode + "");
ServletOutputStream out = response.getOutputStream();
out.write("<HTML>\n".getBytes(encode));
out.write("<HEAD>\n".getBytes(encode));
out.write("<SCRIPT lang=\"JavaScript\">\n".getBytes(encode));
out.write("<!--\n".getBytes(encode));
out.write("function moveToNext() {\n".getBytes(encode));
out.write("document.next.submit();\n".getBytes(encode));
out.write("}\n".getBytes(encode));
out.write("//-->\n".getBytes(encode));
out.write("</SCRIPT>\n".getBytes(encode));
out.write("</HEAD>\n".getBytes(encode));
out.write("<BODY onLoad=\"moveToNext();\">\n".getBytes(encode));
out.write(
(
"<FORM name=\"next\" method=\"POST\" action=\""
+ url
+ "\">\n").getBytes(
encode));
out.write("<INPUT type=\"hidden\" name=\"".getBytes(encode));
out.write(applicationParamName.getBytes(encode));
out.write("\" value=\"".getBytes(encode));
out.write(application.getBytes(encode));
out.write("\">\n".getBytes(encode));
out.write("<INPUT type=\"hidden\" name=\"".getBytes(encode));
out.write(serviceParamName.getBytes(encode));
out.write("\" value=\"".getBytes(encode));
out.write(service.getBytes(encode));
out.write("\">\n".getBytes(encode));
Enumeration paramNames = request.getParameterNames();
while (paramNames.hasMoreElements()) {
String paramName = (String)paramNames.nextElement();
String[] paramValues = request.getParameterValues(paramName);
for (int i = 0; i < paramValues.length; i++) {
out.write("<INPUT type=\"hidden\" name=\"".getBytes(encode));
out.write(paramName.getBytes(encode));
out.write("\" value=\"".getBytes(encode));
out.write(paramValues[i].getBytes(encode));
out.write("\">\n".getBytes(encode));
}
}
out.write("</FORM>\n".getBytes(encode));
out.write("</BODY>\n".getBytes(encode));
out.write("</HTML>\n".getBytes(encode));
out.flush();
out.close();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -