📄 paramservlet.java
字号:
/*
* Created on 2006-4-15
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package com.bookstore.svlt;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
/**
* @author chengqiang
*
*/
public class ParamServlet extends HttpServlet
{
/**
*
*/
private static final long serialVersionUID = -1786344672836615104L;
public String url;
public String pid;
public String targetId;
public String urlerr;
public String callerUrl;
public String action;
public String actionCmd;
public String msg;
public String unitId;
public String unitName;
public HttpSession bySession;
public boolean debug;
public void byHttpService(HttpServletRequest request, HttpServletResponse response , String charSet)
throws ServletException, IOException
{
request.setCharacterEncoding(charSet);
response.setContentType("text/html;charset="+charSet);
bySession = createGetSession(request);
getByUrl(request);
getByUnitId(request);
getByUrlErr(request);
actionCmd = getByAction(request);
getByTargetId(request);
getByPid(request);
getByMsg(request);
callerUrl = url;
request.setAttribute("callerUrl", callerUrl);
bySession.setAttribute("callerUrl", callerUrl);
}
public HttpSession createGetSession(HttpServletRequest request)
{
HttpSession s = request.getSession(false);
if(s == null)
s = request.getSession(true);
return s;
}
public void getByUrl(HttpServletRequest request)
{
try
{
url = request.getParameter("url");
if(url == null || url == "")
url = (String)bySession.getAttribute("url");
if(url == null || url == "")
url = (String)request.getAttribute("url");
}
catch(Exception exception) { }
finally { }
}
public String getByAction(HttpServletRequest request)
{
try
{
action = request.getParameter("action");
if(action == null || action == "")
action = (String)bySession.getAttribute("action");
if(action == null || action == "")
action = (String)request.getAttribute("action");
return action;
}
catch(Exception ex)
{
return null;
}
}
public void getByUnitId(HttpServletRequest request)
{
try
{
unitId = request.getParameter("unitId");
if(unitId == null || unitId == "")
unitId = (String)bySession.getAttribute("unitId");
if(unitId == null || unitId == "")
unitId = (String)request.getAttribute("unitId");
}
catch(Exception exception) { }
finally { }
}
public void getByTargetId(HttpServletRequest request)
{
try
{
targetId = request.getParameter("targetId");
if(targetId == null || targetId == "")
targetId = (String)bySession.getAttribute("targetId");
if(targetId == null || targetId == "")
targetId = (String)request.getAttribute("targetId");
}
catch(Exception exception) { }
finally { }
}
public void getByPid(HttpServletRequest request)
{
try
{
pid = request.getParameter("pid");
if(pid == null || pid == "")
pid = (String)bySession.getAttribute("pid");
if(pid == null || pid == "")
pid = (String)request.getAttribute("pid");
}
catch(Exception exception) { }
}
public void getByMsg(HttpServletRequest request)
{
try
{
msg = request.getParameter("msg");
if(msg == null || msg == "")
msg = (String)bySession.getAttribute("msg");
if(msg == null || msg == "")
msg = (String)request.getAttribute("msg");
}
catch(Exception exception) { }
}
public void getByUrlErr(HttpServletRequest request)
{
try
{
urlerr = request.getParameter("urlerr");
if(urlerr == null || urlerr == "")
urlerr = (String)bySession.getAttribute("urlerr");
if(urlerr == null || urlerr == "")
urlerr = (String)request.getAttribute("urlerr");
}
catch(Exception exception) { }
finally { }
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -