(接上期)
Web tier
当使用者输入http://localhost:8080/petstore/customer.do,MainServlet接收到
Request,转到doProcess()函数:
private void doProcess(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
// set the locale of the user to default if not set
if (request.getSession().getAttribute(WebKeys.LOCALE) == null) {
request.getSession().setAttribute(WebKeys.LOCALE, defaultLocale);
}
try {
getRequestProcessor().processRequest(request);
//进行转导动作(forward)
getScreenFlowManager().forwardToNextScreen(request,response);
} catch (Throwable ex) {
String className = ex.getClass().getName();
String nextScreen = getScreenFlowManager().getExceptionScreen(ex);
// put the exception in the request
request.setAttribute("javax.servlet.jsp.jspException", ex);
if (nextScreen == null) {
// send to general error screen
ex.printStackTrace();
throw new ServletException("MainServlet: unknown exception: " +
className);
}
context.getRequestDispatcher(nextScreen).forward(request, response);
}
}
请开启
Petstore_home\src\waf\src\controller\com\sun\j2ee\blueprints\waf\controller\web\flow\ScreenFlowManager.java
,在约112列可找到forwardToNextScreen()函数:
public void forwardToNextScreen(HttpServletRequest request, HttpServletResponse
response) throws java.io.IOException, FlowHandlerException,
javax.servlet.ServletException {
// set the presious screen
String fullURL = request.getRequestURI();
// get the screen name
String selectedURL = defaultScreen;
int lastPathSeparator = fullURL.lastIndexOf("/") + 1;
if (lastPathSeparator != -1) {
selectedURL = fullURL.substring(lastPathSeparator, fullURL.length());
}
//请加入侦察码,以本例来说,selectedURL=customer.do
System.out.println("selectURL="+ selectedURL);
String currentScreen = "";
URLMapping urlMapping = getURLMapping(selectedURL);






