FileDocCategorySizeDatePackage
JWSAdHocServlet.javaAPI DocGlassfish v2 API6053Fri May 04 22:34:12 BST 2007com.sun.enterprise.appclient.jws

JWSAdHocServlet

public class JWSAdHocServlet extends HttpServlet
Ad hoc servlet registered to receive requests for the user-specified (or defaulted) context-root.

The user can (but is not required to) specify a context root in the runtime deployment descriptor for the app client. That context root - of, if omitted, a default value computed by the app server - is registered dynamically so requests to that context root are routed to an instance of this servlet. In turn, this servlet forwards such requests to the system web application that actually processes all Java Web Start requests for app clients.

author
tjquinn

Fields Summary
public static final String
CONTEXT_ROOT_PARAMETER_NAME
servlet init parameter name for specifying the context root value
public static final String
CATEGORY_PARAMETER_NAME
servlet init parameter name for specifying the category value (appclient or application)
private ServletContext
jwsAppContext
the context for the system web app that handles all Java Web Start requests
private RequestDispatcher
systemWebAppDispatcher
a dispatcher used in forwarding requests to the system web app
private String
targetContextRoot
the actual context root, obtained from the init parameter, to which reqs should be dispatched
private String
category
the category from the init parameter
Constructors Summary
public JWSAdHocServlet()
Creates a new instance of JWSAdHocServlet

    
           
      
    
Methods Summary
private javax.servlet.ServletContextgetJWSAppContext()
Returns the context for the Java Web Start app client system web app.

return
the servlet context for the system web app

        if (jwsAppContext == null) {
            String uri = NamingConventions.webAppURI();
            jwsAppContext = getServletContext().getContext(uri);
        }
        return jwsAppContext;
    
private javax.servlet.RequestDispatchergetJWSRequestDispatcher()
Returns the dispatcher to the system web app.

return
the request dispatcher

        if (systemWebAppDispatcher == null) {
            String uri = NamingConventions.webAppURI();
            WebPath webPath = new WebPath(uri);
            
            ServletContext sc = getServletContext().getContext(webPath.contextRoot());
            String servletContextName = sc.getServletContextName();
            systemWebAppDispatcher = sc.getRequestDispatcher(webPath.path() + "/" + category + targetContextRoot);
        }
        return systemWebAppDispatcher;
    
public voidinit()
Init method responsible for retrieiving init params.

        ServletConfig config = getServletConfig();
        
        targetContextRoot = config.getInitParameter(CONTEXT_ROOT_PARAMETER_NAME);
        category = config.getInitParameter(CATEGORY_PARAMETER_NAME);
    
protected voidservice(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
Responds to any method.

param
the incoming request
param
the outgoing response
throws
ServletException in case of any errors

        /*
         *Use the context for the Java Web Start system web app and forward this request
         *to that app.
         */
        JWSAdHocServletRequestWrapper wrappedRequest = new JWSAdHocServletRequestWrapper(request, targetContextRoot, category);
        try {
            getJWSRequestDispatcher().forward(wrappedRequest, response);
        } catch (Throwable thr) {
            throw new ServletException("Error dispatching request to Java Web Start app client application", thr);
        }