Java Code Examples for javax.servlet.RequestDispatcher

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project alphaportal_dev, under directory /sys-src/alphaportal/web/src/test/java/alpha/portal/webapp/filter/.

Source file: MockFilterChain.java

  24 
vote

public void doFilter(final ServletRequest request,final ServletResponse response) throws IOException, ServletException {
  String uri=((HttpServletRequest)request).getRequestURI();
  final String requestContext=((HttpServletRequest)request).getContextPath();
  if (StringUtils.isNotEmpty(requestContext) && uri.startsWith(requestContext)) {
    uri=uri.substring(requestContext.length());
  }
  this.forwardURL=uri;
  this.log.debug("Forwarding to: " + uri);
  final RequestDispatcher dispatcher=request.getRequestDispatcher(uri);
  dispatcher.forward(request,response);
}
 

Example 2

From project com.idega.content, under directory /src/java/com/idega/content/filter/.

Source file: ContentDispatcher.java

  23 
vote

public void doFilter(ServletRequest srequest,ServletResponse sresponse,FilterChain chain) throws IOException, ServletException {
  HttpServletRequest request=(HttpServletRequest)srequest;
  String jackrabbitBasePath="/repository/default";
  if (contentRepository.equals(CONTENT_REPOSITORY_JACKRABBIT)) {
    String url=getURIMinusContextPath(request);
    String newUrl=jackrabbitBasePath + url;
    RequestDispatcher dispatcher=request.getRequestDispatcher(newUrl);
    dispatcher.include(srequest,sresponse);
  }
 else {
    chain.doFilter(srequest,sresponse);
  }
}
 

Example 3

From project Extlet6, under directory /liferay-6.0.5-patch/portal-impl/src/com/liferay/portal/servlet/.

Source file: MainServlet.java

  22 
vote

protected boolean processMaintenanceRequest(HttpServletRequest request,HttpServletResponse response) throws IOException, ServletException {
  if (!MaintenanceUtil.isMaintaining()) {
    return false;
  }
  RequestDispatcher requestDispatcher=request.getRequestDispatcher("/html/portal/maintenance.jsp");
  requestDispatcher.include(request,response);
  return true;
}
 

Example 4

From project frascati-studio-social, under directory /src/servlet/.

Source file: AdminServlet.java

  22 
vote

public void doGet(HttpServletRequest req,HttpServletResponse rep) throws IOException, ServletException {
  String next;
  try {
    IAction action=getAction(req.getParameter("cmd"));
    next=action.execute(req);
  }
 catch (  Exception e) {
    req.setAttribute("erreur",e.getMessage());
    next="jsp/erreur.jsp";
  }
  RequestDispatcher rd=sc.getRequestDispatcher("/" + next);
  rd.forward(req,rep);
}
 

Example 5

From project guice-jit-providers, under directory /extensions/servlet/src/com/google/inject/servlet/.

Source file: ManagedFilterPipeline.java

  22 
vote

/** 
 * Used to create an proxy that dispatches either to the guice-servlet pipeline or the regular pipeline based on uri-path match. This proxy also provides minimal forwarding support. We cannot forward from a web.xml Servlet/JSP to a guice-servlet (because the filter pipeline is not called again). However, we can wrap requests with our own dispatcher to forward the *other* way. web.xml Servlets/JSPs can forward to themselves as per normal. This is not a problem cuz we intend for people to migrate from web.xml to guice-servlet, incrementally, but not the other way around (which, we should actively discourage).
 */
@SuppressWarnings({"JavaDoc","deprecation"}) private ServletRequest withDispatcher(ServletRequest servletRequest,final ManagedServletPipeline servletPipeline){
  if (!servletPipeline.hasServletsMapped()) {
    return servletRequest;
  }
  HttpServletRequest request=(HttpServletRequest)servletRequest;
  return new HttpServletRequestWrapper(request){
    @Override public RequestDispatcher getRequestDispatcher(    String path){
      final RequestDispatcher dispatcher=servletPipeline.getRequestDispatcher(path);
      return (null != dispatcher) ? dispatcher : super.getRequestDispatcher(path);
    }
  }
;
}
 

Example 6

From project Hackathon_Chutaum, under directory /src/br/com/chutaum/servlet/.

Source file: DislikeServlet.java

  22 
vote

@Override protected void doGet(HttpServletRequest req,HttpServletResponse resp) throws ServletException, IOException {
  User user=UserController.currentUser(req.getSession());
  String actionId=req.getParameter("id");
  String mail=req.getParameter("mail");
  if (user != null) {
    if (user.getEmail().equals(mail)) {
      UserController.DislikeAction(mail,actionId);
      req.setAttribute("action",PoliticianController.findAction(actionId));
      RequestDispatcher rd=req.getRequestDispatcher("like.jsp");
      rd.forward(req,resp);
    }
  }
}
 

Example 7

From project jclouds-chef, under directory /demos/gae/src/main/java/org/jclouds/chef/demo/controllers/.

Source file: GetNodeStatusController.java

  22 
vote

@Override protected void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
  try {
    addStatusResultsToRequest(request);
    RequestDispatcher dispatcher=getServletContext().getRequestDispatcher("/WEB-INF/jsp/status.jsp");
    dispatcher.forward(request,response);
  }
 catch (  Exception e) {
    logger.error(e,"Error listing status");
    throw new ServletException(e);
  }
}
 

Example 8

From project lyo.rio, under directory /org.eclipse.lyo.rio.am/src/main/java/org/eclipse/lyo/oslc/am/linktype/.

Source file: LinkTypeSelectorService.java

  22 
vote

protected void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
  String terms=request.getParameter("terms");
  if (terms != null) {
    sendQueryResponse(terms,response);
  }
 else {
    RequestDispatcher rd=request.getRequestDispatcher("/am/linktype_selector.jsp");
    rd.forward(request,response);
  }
}
 

Example 9

From project lyo.server, under directory /org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/.

Source file: RootServicesService.java

  22 
vote

/** 
 * @see HttpServlet#doGet(HttpServletRequest request,HttpServletResponse response)
 */
protected void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
  System.err.println("RootServices.doGET - Accept: " + request.getHeader("Accept"));
  request.setAttribute("baseUri",BugzillaInitializer.getBaseUri());
  final RequestDispatcher rd=request.getRequestDispatcher("/cm/rootservices_rdfxml.jsp");
  rd.forward(request,response);
  response.flushBuffer();
}
 

Example 10

From project maven-gae-plugin, under directory /gae-archetype-jsp/src/main/resources/archetype-resources/src/main/java/web/.

Source file: IndexServlet.java

  22 
vote

/** 
 * Forwards request and response to given path. Handles any exceptions caused by forward target by printing them to logger.
 * @param request 
 * @param response
 * @param path 
 */
protected void forward(HttpServletRequest request,HttpServletResponse response,String path){
  try {
    RequestDispatcher rd=request.getRequestDispatcher(path);
    rd.forward(request,response);
  }
 catch (  Throwable tr) {
    if (log.isErrorEnabled()) {
      log.error("Cought Exception: " + tr.getMessage());
      log.debug("StackTrace:",tr);
    }
  }
}
 

Example 11

From project Mockey, under directory /src/java/com/mockey/ui/.

Source file: ProxyInfoServlet.java

  22 
vote

/** 
 * @param req basic request
 * @param resp basic resp
 * @throws ServletException basic
 * @throws IOException basic
 */
public void doGet(HttpServletRequest req,HttpServletResponse resp) throws ServletException, IOException {
  ProxyServerModel proxyInfo=store.getProxy();
  req.setAttribute("proxyInfo",proxyInfo);
  RequestDispatcher dispatch=req.getRequestDispatcher("/proxy_setup.jsp");
  dispatch.forward(req,resp);
}
 

Example 12

From project netnumeri, under directory /lib/appengine-java-sdk-1.6.0/demos/mediastore/src/com/google/appengine/demos/mediastore/.

Source file: Upload.java

  22 
vote

public void doGet(HttpServletRequest req,HttpServletResponse resp) throws IOException, ServletException {
  UserService userService=UserServiceFactory.getUserService();
  User user=userService.getCurrentUser();
  String authURL=userService.createLogoutURL("/");
  String uploadURL=blobstoreService.createUploadUrl("/post");
  req.setAttribute("uploadURL",uploadURL);
  req.setAttribute("authURL",authURL);
  req.setAttribute("user",user);
  RequestDispatcher dispatcher=req.getRequestDispatcher("WEB-INF/templates/upload.jsp");
  dispatcher.forward(req,resp);
}
 

Example 13

From project onebusaway-nyc, under directory /onebusaway-nyc-api-webapp/src/main/java/org/onebusaway/api/impl/.

Source file: XmlResult.java

  22 
vote

@Override protected void doExecute(String finalLocation,ActionInvocation invocation) throws Exception {
  HttpServletRequest request=ServletActionContext.getRequest();
  HttpServletResponse response=ServletActionContext.getResponse();
  RequestDispatcher dispatcher=request.getRequestDispatcher(finalLocation);
  response.setContentType("text/xml");
  dispatcher.include(request,response);
}
 

Example 14

From project ontology-broker, under directory /src/org/sc/probro/servlets/.

Source file: SkeletonServlet.java

  22 
vote

public JSONObject getLocalJSON(HttpServletRequest req,String path) throws ServletException, IOException, JSONException, BrokerException {
  RequestDispatcher dispatcher=getServletContext().getRequestDispatcher(path);
  DummyServletResponse response=new DummyServletResponse();
  dispatcher.include(req,response);
  if (response.getStatus() != HttpServletResponse.SC_OK) {
    throw new BrokerException(response.getStatus(),response.getValue());
  }
  String value=response.getValue();
  Log.info(value);
  return new JSONObject(value);
}
 

Example 15

From project orion.server, under directory /bundles/org.eclipse.orion.server.authentication/src/org/eclipse/orion/server/authentication/formopenid/.

Source file: FormOpenIdLoginServlet.java

  22 
vote

protected void doGet(HttpServletRequest req,HttpServletResponse resp) throws ServletException, IOException {
  String pathInfo=req.getPathInfo() == null ? "" : req.getPathInfo();
  if (pathInfo.startsWith("/openid") && (req.getParameter(OpenIdHelper.OPENID) != null || req.getParameter(OpenIdHelper.OP_RETURN) != null)) {
    doPost(req,resp);
    return;
  }
  RequestDispatcher rd=req.getRequestDispatcher("/mixlogin/login");
  rd.forward(req,resp);
}
 

Example 16

From project picketbox-http, under directory /src/main/java/org/picketbox/http/authentication/.

Source file: AbstractHTTPAuthentication.java

  22 
vote

protected void forwardLoginPage(HttpServletRequest request,HttpServletResponse response) throws AuthenticationException {
  RequestDispatcher rd=request.getServletContext().getRequestDispatcher(this.formAuthPage);
  if (rd == null)   throw MESSAGES.unableToFindRequestDispatcher();
  try {
    rd.forward(request,response);
  }
 catch (  Exception e) {
    throw new AuthenticationException(e);
  }
}
 

Example 17

From project pluto, under directory /pluto-container/src/main/java/org/apache/pluto/container/impl/.

Source file: RequestDispatcherServiceImpl.java

  22 
vote

public PortletRequestDispatcher getNamedDispatcher(ServletContext servletContext,PortletApplicationDefinition app,String name){
  if (LOG.isDebugEnabled()) {
    LOG.debug("Named PortletRequestDispatcher requested for name: " + name + " at context: "+ app.getContextPath());
  }
  RequestDispatcher dispatcher=servletContext.getNamedDispatcher(name);
  if (dispatcher != null) {
    return new PortletRequestDispatcherImpl(dispatcher,true);
  }
  if (LOG.isInfoEnabled()) {
    LOG.info("No matching request dispatcher found for name: " + name);
  }
  return null;
}
 

Example 18

From project portlet-utils, under directory /portal-rest-api/src/main/java/org/jasig/portlet/utils/rest/.

Source file: SimpleCrossContextRestApiInvoker.java

  22 
vote

private RestResponse doInvoke(HttpServletRequest req,HttpServletResponse res,UriTuple tuple){
  try {
    ServletContext ctx=req.getSession().getServletContext().getContext(tuple.getContextName());
    RequestDispatcher rd=ctx.getRequestDispatcher(tuple.getUri());
    HttpServletResponseWrapperImpl responseWrapper=new HttpServletResponseWrapperImpl(res);
    rd.include(req,responseWrapper);
    RestResponse rslt=new RestResponse(responseWrapper.getOutputAsString(),responseWrapper.getContentType());
    return rslt;
  }
 catch (  Exception e) {
    throw new RuntimeException(e);
  }
}
 

Example 19

From project repose, under directory /project-set/core/core-lib/src/test/java/com/rackspace/papi/filter/.

Source file: ServletContextWrapperTest.java

  22 
vote

@Test public void shouldReturnRemoteDispatcherForFullUrl(){
  final String target="somehost:8080";
  final String subcontext="http://" + target + "/somepath";
  ServletContext context=instance.getContext(subcontext);
  assertTrue(context instanceof ServletContextWrapper);
  ServletContextWrapper wrapped=(ServletContextWrapper)context;
  RequestDispatcher requestDispatcher=wrapped.getRequestDispatcher(subcontext);
  assertNotNull(requestDispatcher);
  assertTrue(requestDispatcher instanceof HttpRequestDispatcher);
}
 

Example 20

From project sandbox, under directory /xwiki-portlet/src/main/java/org/xwiki/portlet/controller/.

Source file: DispatchedRequest.java

  22 
vote

/** 
 * {@inheritDoc}<p> We wrap the request dispatcher to be notified whenever this request is forwarded or included. We have to do this in order to update the path info.
 * @see HttpServletRequestWrapper#getRequestDispatcher(String)
 */
@Override public RequestDispatcher getRequestDispatcher(String path){
  RequestDispatcher dispatcher=super.getRequestDispatcher(path);
  if (dispatcher != null) {
    return new NotifyingRequestDispatcher(dispatcher,this,path);
  }
 else {
    return null;
  }
}
 

Example 21

From project scooter, under directory /source/src/com/scooterframework/web/controller/.

Source file: ActionControl.java

  22 
vote

/** 
 * <p>Do a forward to specified URI using a <tt>RequestDispatcher</tt>. This method is used by all methods needing to do a forward.</p>
 * @param uri Context-relative URI to forward to
 * @param request HTTP servlet request
 * @param response HTTP servlet response
 * @throws java.io.IOException
 * @throws javax.servlet.ServletException
 */
public static void doForward(String uri,HttpServletRequest request,HttpServletResponse response) throws IOException, ServletException {
  log.debug("doForward: " + uri);
  if (uri == null)   return;
  if (uri != null && !uri.startsWith("/"))   uri="/" + uri;
  RequestDispatcher rd=request.getSession().getServletContext().getRequestDispatcher(uri);
  if (rd == null) {
    uri="/WEB-INF/views/404.jsp";
    log.error("Unable to locate \"" + uri + "\", forward to "+ uri);
    rd=getServletContext().getRequestDispatcher(uri);
  }
  rd.forward(request,response);
}
 

Example 22

From project sisu-guice, under directory /extensions/servlet/src/com/google/inject/servlet/.

Source file: ManagedFilterPipeline.java

  22 
vote

/** 
 * Used to create an proxy that dispatches either to the guice-servlet pipeline or the regular pipeline based on uri-path match. This proxy also provides minimal forwarding support. We cannot forward from a web.xml Servlet/JSP to a guice-servlet (because the filter pipeline is not called again). However, we can wrap requests with our own dispatcher to forward the *other* way. web.xml Servlets/JSPs can forward to themselves as per normal. This is not a problem cuz we intend for people to migrate from web.xml to guice-servlet, incrementally, but not the other way around (which, we should actively discourage).
 */
@SuppressWarnings({"JavaDoc","deprecation"}) private ServletRequest withDispatcher(ServletRequest servletRequest,final ManagedServletPipeline servletPipeline){
  if (!servletPipeline.hasServletsMapped()) {
    return servletRequest;
  }
  HttpServletRequest request=(HttpServletRequest)servletRequest;
  return new HttpServletRequestWrapper(request){
    @Override public RequestDispatcher getRequestDispatcher(    String path){
      final RequestDispatcher dispatcher=servletPipeline.getRequestDispatcher(path);
      return (null != dispatcher) ? dispatcher : super.getRequestDispatcher(path);
    }
  }
;
}
 

Example 23

From project skalli, under directory /org.eclipse.skalli.view/src/main/java/org/eclipse/skalli/view/internal/filter/.

Source file: FilterUtil.java

  22 
vote

public static void handleException(ServletRequest request,ServletResponse response,Exception e) throws ServletException, IOException {
  if (!response.isCommitted()) {
    RequestDispatcher rd=request.getRequestDispatcher(Consts.URL_ERROR);
    request.setAttribute(Consts.ATTRIBUTE_EXCEPTION,e);
    rd.forward(request,response);
  }
}
 

Example 24

From project spring-security, under directory /web/src/main/java/org/springframework/security/web/access/.

Source file: AccessDeniedHandlerImpl.java

  22 
vote

public void handle(HttpServletRequest request,HttpServletResponse response,AccessDeniedException accessDeniedException) throws IOException, ServletException {
  if (!response.isCommitted()) {
    if (errorPage != null) {
      request.setAttribute(WebAttributes.ACCESS_DENIED_403,accessDeniedException);
      response.setStatus(HttpServletResponse.SC_FORBIDDEN);
      RequestDispatcher dispatcher=request.getRequestDispatcher(errorPage);
      dispatcher.forward(request,response);
    }
 else {
      response.sendError(HttpServletResponse.SC_FORBIDDEN,accessDeniedException.getMessage());
    }
  }
}
 

Example 25

From project teatrove, under directory /teaservlet/src/main/java/org/teatrove/teaservlet/.

Source file: HttpContextImpl.java

  22 
vote

public void insertPath(String path){
  try {
    if (path.trim().startsWith("/") == false)     path="/" + path.trim();
    RequestDispatcher disp=mServletContext.getRequestDispatcher(path);
    disp.include(mRequest,mResponse);
  }
 catch (  Exception ex) {
    mLog.error(ex);
  }
}
 

Example 26

From project tiles, under directory /tiles-servlet/src/test/java/org/apache/tiles/web/util/.

Source file: ServletContextAdapterTest.java

  22 
vote

/** 
 * Test method for  {@link org.apache.tiles.web.util.ServletContextAdapter#getRequestDispatcher(java.lang.String)}.
 */
@Test public void testGetRequestDispatcher(){
  RequestDispatcher is=createMock(RequestDispatcher.class);
  expect(servletContext.getRequestDispatcher("whatever")).andReturn(is);
  replay(servletContext,config,is);
  ServletContextAdapter adapter=new ServletContextAdapter(config);
  assertEquals(is,adapter.getRequestDispatcher("whatever"));
  verify(is);
}
 

Example 27

From project tiles-request, under directory /tiles-request-servlet/src/main/java/org/apache/tiles/request/servlet/.

Source file: ServletRequest.java

  22 
vote

/** 
 * {@inheritDoc} 
 */
public void doInclude(String path) throws IOException {
  RequestDispatcher rd=request.getRequestDispatcher(path);
  if (rd == null) {
    throw new IOException("No request dispatcher returned for path '" + path + "'");
  }
  try {
    rd.include(request,response);
  }
 catch (  ServletException ex) {
    throw ServletUtil.wrapServletException(ex,"ServletException including path '" + path + "'.");
  }
}
 

Example 28

From project turismo, under directory /src/main/java/com/ghosthack/turismo/action/behavior/.

Source file: Alias.java

  22 
vote

public void forward(final String target){
  final RequestDispatcher dispatcher=Env.ctx().getRequestDispatcher(target);
  try {
    dispatcher.forward(Env.req(),Env.res());
  }
 catch (  ServletException e) {
    throw new ActionException(e);
  }
catch (  IOException e) {
    throw new ActionException(e);
  }
}
 

Example 29

From project undertow, under directory /servlet/src/test/java/io/undertow/servlet/test/dispatcher/.

Source file: IncludeServlet.java

  22 
vote

@Override protected void doGet(final HttpServletRequest req,final HttpServletResponse resp) throws ServletException, IOException {
  resp.getWriter().write(MESSAGE);
  RequestDispatcher dispatcher;
  if (req.getHeader("name") != null) {
    dispatcher=req.getServletContext().getNamedDispatcher(req.getHeader("include"));
  }
 else {
    dispatcher=req.getRequestDispatcher(req.getHeader("include"));
  }
  dispatcher.include(req,resp);
}
 

Example 30

From project virgo.web, under directory /test-apps/webfeature-tests/src/main/java/webfeature/tests/.

Source file: ForwardServlet.java

  22 
vote

public void doGet(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException {
  res.setContentType("text/plain");
  PrintWriter writer=res.getWriter();
  writer.write("Before forwarding the request to /fa in DispatcherServlet\n");
  RequestDispatcher dispatcher=req.getRequestDispatcher("/fa");
  if (dispatcher != null) {
    dispatcher.forward(req,res);
  }
  writer.write("\nAfter forwarding the request to /fa in DispatcherServlet");
}
 

Example 31

From project wayback, under directory /wayback-core/src/main/java/org/archive/wayback/accesspoint/proxy/.

Source file: IPProxyConfigSelector.java

  22 
vote

public boolean selectConfigHandler(HttpServletRequest request,HttpServletResponse response,ProxyAccessPoint proxy) throws IOException {
  request.setAttribute("proxyAccessPoint",proxy);
  RequestDispatcher dispatcher=request.getRequestDispatcher(proxyInfoJsp);
  try {
    dispatcher.forward(request,response);
  }
 catch (  ServletException e) {
    e.printStackTrace();
  }
  return true;
}
 

Example 32

From project wiremock, under directory /src/main/java/com/github/tomakehurst/wiremock/servlet/.

Source file: TrailingSlashFilter.java

  22 
vote

@Override public void sendRedirect(String location) throws IOException {
  if (location.contains(path)) {
    RequestDispatcher dispatcher=request.getRequestDispatcher(getPathPartFromLocation(location));
    try {
      dispatcher.forward(request,this);
    }
 catch (    ServletException se) {
      throw new IOException(se);
    }
  }
}
 

Example 33

From project arquillian-container-weld, under directory /weld-ee-embedded-1.1/src/main/java/org/jboss/arquillian/container/weld/ee/embedded_1_1/mock/.

Source file: MockServletContext.java

  21 
vote

/** 
 * Wicket does not use the RequestDispatcher, so this implementation just returns a dummy value.
 * @param name The name of the resource to get the dispatcher for
 * @return The dispatcher
 */
public RequestDispatcher getRequestDispatcher(final String name){
  return new RequestDispatcher(){
    public void forward(    ServletRequest servletRequest,    ServletResponse servletResponse) throws IOException {
      servletResponse.getWriter().write("FORWARD TO RESOURCE: " + name);
    }
    public void include(    ServletRequest servletRequest,    ServletResponse servletResponse) throws IOException {
      servletResponse.getWriter().write("INCLUDE OF RESOURCE: " + name);
    }
  }
;
}
 

Example 34

From project arquillian-weld-embedded-1.1, under directory /src/main/java/org/jboss/arquillian/container/weld/ee/embedded_1_1/mock/.

Source file: MockServletContext.java

  21 
vote

/** 
 * Wicket does not use the RequestDispatcher, so this implementation just returns a dummy value.
 * @param name The name of the resource to get the dispatcher for
 * @return The dispatcher
 */
public RequestDispatcher getRequestDispatcher(final String name){
  return new RequestDispatcher(){
    public void forward(    ServletRequest servletRequest,    ServletResponse servletResponse) throws IOException {
      servletResponse.getWriter().write("FORWARD TO RESOURCE: " + name);
    }
    public void include(    ServletRequest servletRequest,    ServletResponse servletResponse) throws IOException {
      servletResponse.getWriter().write("INCLUDE OF RESOURCE: " + name);
    }
  }
;
}
 

Example 35

From project arquillian_deprecated, under directory /containers/weld-ee-embedded-1.1/src/main/java/org/jboss/arquillian/container/weld/ee/embedded_1_1/mock/.

Source file: MockServletContext.java

  21 
vote

/** 
 * Wicket does not use the RequestDispatcher, so this implementation just returns a dummy value.
 * @param name The name of the resource to get the dispatcher for
 * @return The dispatcher
 */
public RequestDispatcher getRequestDispatcher(final String name){
  return new RequestDispatcher(){
    public void forward(    ServletRequest servletRequest,    ServletResponse servletResponse) throws IOException {
      servletResponse.getWriter().write("FORWARD TO RESOURCE: " + name);
    }
    public void include(    ServletRequest servletRequest,    ServletResponse servletResponse) throws IOException {
      servletResponse.getWriter().write("INCLUDE OF RESOURCE: " + name);
    }
  }
;
}
 

Example 36

From project aws-tvm-anonymous, under directory /src/com/amazonaws/tvm/.

Source file: RootServlet.java

  21 
vote

public void doGet(HttpServletRequest request,HttpServletResponse response) throws IOException, ServletException {
  try {
    String forwardTo=null;
    try {
      forwardTo=this.processRequest(request,response);
    }
 catch (    Exception exception) {
      this.handleException(request,response,exception);
    }
    if (forwardTo != null) {
      RequestDispatcher dispatcher=getServletContext().getRequestDispatcher(forwardTo);
      dispatcher.forward(request,response);
    }
  }
 catch (  Exception exception) {
    throw new ServletException(exception);
  }
}
 

Example 37

From project aws-tvm-identity, under directory /src/com/amazonaws/tvm/.

Source file: RootServlet.java

  21 
vote

public void doGet(HttpServletRequest request,HttpServletResponse response) throws IOException, ServletException {
  try {
    String forwardTo=null;
    try {
      forwardTo=this.processRequest(request,response);
    }
 catch (    Exception exception) {
      this.handleException(request,response,exception);
    }
    if (forwardTo != null) {
      RequestDispatcher dispatcher=getServletContext().getRequestDispatcher(forwardTo);
      dispatcher.forward(request,response);
    }
  }
 catch (  Exception exception) {
    throw new ServletException(exception);
  }
}
 

Example 38

From project azure4j-blog-samples, under directory /ACSExample/src/com/persistent/azure/acs/servlet/.

Source file: IdentityBasedAccessServlet.java

  21 
vote

/** 
 * @see HttpServlet#doGet(HttpServletRequest request,HttpServletResponse response)
 */
protected void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
  String identityProvider=request.getParameter("idp");
  String currentIdentityProvider=null;
  String dispatchTo=null;
  Cookie[] cookies=request.getCookies();
  Cookie currentCookie=null;
  String cookieName=resourceBundle.getString("acs.cookie.name");
  if (cookies != null && cookies.length > 0) {
    for (    Cookie c : cookies) {
      if (cookieName.equals(c.getName())) {
        currentCookie=c;
        break;
      }
    }
  }
  if (currentCookie != null) {
    String separator=resourceBundle.getString("acs.separator");
    String[] arrValue=currentCookie.getValue().split(separator);
    currentIdentityProvider=arrValue[0];
    if (currentIdentityProvider.equalsIgnoreCase(identityProvider)) {
      dispatchTo="/WEB-INF/pages/authorized.jsp";
    }
 else {
      dispatchTo="/WEB-INF/pages/unAuthorized.jsp";
    }
    request.setAttribute("currentIdentityProvider",currentIdentityProvider);
  }
  RequestDispatcher reqDispatcher=request.getRequestDispatcher(dispatchTo);
  reqDispatcher.forward(request,response);
}
 

Example 39

From project b3log-latke, under directory /latke/src/main/java/org/b3log/latke/servlet/.

Source file: HTTPRequestDispatcher.java

  21 
vote

/** 
 * Serves.
 * @param request the specified HTTP servlet request
 * @param response the specified HTTP servlet response
 * @throws ServletException servlet exception
 * @throws IOException io exception
 */
@Override protected void service(final HttpServletRequest request,final HttpServletResponse response) throws ServletException, IOException {
  final String resourcePath=request.getPathTranslated();
  final String requestURI=request.getRequestURI();
  LOGGER.log(Level.FINEST,"Request[contextPath={0}, pathTranslated={1}, requestURI={2}]",new Object[]{request.getContextPath(),resourcePath,requestURI});
  if (StaticResources.isStatic(request)) {
    final RequestDispatcher requestDispatcher=getServletContext().getNamedDispatcher(defaultServletName);
    if (null == requestDispatcher) {
      throw new IllegalStateException("A RequestDispatcher could not be located for the default servlet [" + this.defaultServletName + "]");
    }
    requestDispatcher.forward(request,response);
    return;
  }
  final long startTimeMillis=System.currentTimeMillis();
  request.setAttribute(Keys.HttpRequest.START_TIME_MILLIS,startTimeMillis);
  if (Latkes.isPageCacheEnabled()) {
    final String queryString=request.getQueryString();
    String pageCacheKey=(String)request.getAttribute(Keys.PAGE_CACHE_KEY);
    if (Strings.isEmptyOrNull(pageCacheKey)) {
      pageCacheKey=PageCaches.getPageCacheKey(requestURI,queryString);
      request.setAttribute(Keys.PAGE_CACHE_KEY,pageCacheKey);
    }
  }
  final HTTPRequestContext context=new HTTPRequestContext();
  context.setRequest(request);
  context.setResponse(response);
  dispatch(context);
}
 

Example 40

From project Blitz, under directory /src/com/laxser/blitz/web/portal/impl/.

Source file: WindowTask.java

  21 
vote

@Override public void run(){
  try {
    window.getContainer().onWindowStarted(window);
    String windowPath=window.getPath();
    if (windowPath.length() == 0 || windowPath.charAt(0) != '/') {
      String requestUri=request.getRequestURI();
      if (!requestUri.endsWith("/")) {
        requestUri=requestUri + "/";
      }
      windowPath=requestUri + windowPath;
    }
    final RequestDispatcher rd=request.getRequestDispatcher(windowPath);
    request.setAttribute("$$blitz-portal.window",window);
    if (this.response.isCommitted()) {
      if (logger.isDebugEnabled()) {
        logger.debug("onWindowTimeout: response has committed. [" + window.getName() + "]@"+ window.getContainer());
      }
      window.getContainer().onWindowTimeout(window);
      return;
    }
    rd.forward(request,this.response);
    window.getContainer().onWindowDone(window);
  }
 catch (  Throwable e) {
    logger.error("",e);
    window.setThrowable(e);
    window.getContainer().onWindowError(window);
  }
 finally {
    final HttpServletRequest wrapper=window.getContainer().getRequest();
    final PortalRequest portalRequest=PortalRequest.unwrapPortalRequest(wrapper);
    portalRequest.setRequest(null);
  }
}
 

Example 41

From project entando-core-engine, under directory /src/main/java/com/agiletec/aps/system/services/controller/control/.

Source file: Executor.java

  21 
vote

@Override public int service(RequestContext reqCtx,int status){
  int retStatus=ControllerManager.INVALID_STATUS;
  if (status == ControllerManager.ERROR) {
    return status;
  }
  Logger log=ApsSystemUtils.getLogger();
  try {
    HttpServletResponse resp=reqCtx.getResponse();
    HttpServletRequest req=reqCtx.getRequest();
    String jspPath="/WEB-INF/aps/jsp/system/main.jsp";
    req.setCharacterEncoding("UTF-8");
    RequestDispatcher dispatcher=req.getRequestDispatcher(jspPath);
    dispatcher.forward(req,resp);
    log.finest("Executed forward to " + jspPath);
    retStatus=ControllerManager.OUTPUT;
  }
 catch (  ServletException t) {
    ApsSystemUtils.logThrowable(t,this,"service","Error while building page portal");
    retStatus=ControllerManager.ERROR;
    reqCtx.setHTTPError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
  }
catch (  Throwable t) {
    ApsSystemUtils.logThrowable(t,this,"service","Error while forwarding to main.jsp");
    retStatus=ControllerManager.SYS_ERROR;
    reqCtx.setHTTPError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
  }
  return retStatus;
}
 

Example 42

From project gatein-wci_1, under directory /wci/src/main/java/org/gatein/wci/command/.

Source file: CommandServlet.java

  21 
vote

/** 
 * <p>Execute a command after having performed a request dispatch in the target servlet context.</p> <p/> <p>The provided callback argument must expose a public non static and non abstract method with the signature <code>execute(HttpServletRequest,HttpServletResponse)</code>. This method must return an object and can declare any exception. This method will be invoked after the request dispatch operation is done.</p> <p/> <p>Any throwable thrown by the callback invocation will be wrapped in a <code>ServletException</code> and rethrown, unless it is an instance of <code>ServletException</code> or <code>IOException</code>.</p>
 * @param servletPath the servlet path on which the command servlet is mapped
 * @param request the servlet container request
 * @param response the servlet container response
 * @param callback      the callback to invoke after the inclusion is done
 * @param targetContext the target servlet context
 * @return the object returned by the callback
 * @throws IOException      likely thrown by the request dispatch operation
 * @throws ServletException wraps any exception thrown by the callback
 */
static Object include(String servletPath,HttpServletRequest request,HttpServletResponse response,Object callback,ServletContext targetContext) throws ServletException, IOException {
  try {
    localCmd.set(callback);
    RequestDispatcher switcher=targetContext.getRequestDispatcher(servletPath);
    switcher.include(request,response);
    Throwable throwable=localThrowable.get();
    if (throwable != null) {
      if (throwable instanceof IOException) {
        throw (IOException)throwable;
      }
 else       if (throwable instanceof ServletException) {
        throw (ServletException)throwable;
      }
 else {
        ServletException se=new ServletException();
        se.initCause(throwable);
        throw se;
      }
    }
    return localResponse.get();
  }
  finally {
    localCmd.set(null);
    localResponse.set(null);
    localThrowable.set(null);
  }
}
 

Example 43

From project interoperability-framework, under directory /interfaces/taverna/T2-Client/workflow-lib/src/main/java/eu/impact_project/iif/t2/client/.

Source file: GroupSelector.java

  21 
vote

/** 
 * Sets the currently selected myExperiment groups
 */
protected void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
  HttpSession session=request.getSession(true);
  int i=0;
  while (request.getParameter("MyExpGroup" + i) != null || request.getAttribute("MyExpGroup" + i) != null) {
    String groupName="";
    String groupParam=request.getParameter("MyExpGroup" + i);
    String groupAttrib=(String)request.getAttribute("MyExpGroup" + i);
    if (groupParam != null) {
      groupName=groupParam;
    }
 else     if (groupAttrib != null) {
      groupName=groupAttrib;
    }
    session.setAttribute("selectedGroupName" + i,groupName);
    String workflowUrl="";
    String workflowParam=request.getParameter("MyExpWorkflow" + i);
    String workflowAttrib=(String)request.getAttribute("MyExpWorkflow" + i);
    if (workflowParam != null) {
      workflowUrl=workflowParam;
    }
 else     if (workflowAttrib != null) {
      workflowUrl=workflowAttrib;
    }
    session.setAttribute("currentWfId" + i,workflowUrl);
    i++;
  }
  RequestDispatcher rd=getServletContext().getRequestDispatcher("/");
  rd.forward(request,response);
}
 

Example 44

From project jAPS2, under directory /src/com/agiletec/aps/system/services/controller/control/.

Source file: Executor.java

  21 
vote

@Override public int service(RequestContext reqCtx,int status){
  int retStatus=ControllerManager.INVALID_STATUS;
  if (status == ControllerManager.ERROR) {
    return status;
  }
  Logger log=ApsSystemUtils.getLogger();
  try {
    HttpServletResponse resp=reqCtx.getResponse();
    HttpServletRequest req=reqCtx.getRequest();
    String jspPath="/WEB-INF/aps/jsp/system/main.jsp";
    req.setCharacterEncoding("UTF-8");
    RequestDispatcher dispatcher=req.getRequestDispatcher(jspPath);
    dispatcher.forward(req,resp);
    log.finest("Executed forward to " + jspPath);
    retStatus=ControllerManager.OUTPUT;
  }
 catch (  ServletException t) {
    ApsSystemUtils.logThrowable(t,this,"service","Error while building page portal");
    retStatus=ControllerManager.ERROR;
    reqCtx.setHTTPError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
  }
catch (  Throwable t) {
    ApsSystemUtils.logThrowable(t,this,"service","Error while forwarding to main.jsp");
    retStatus=ControllerManager.SYS_ERROR;
    reqCtx.setHTTPError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
  }
  return retStatus;
}
 

Example 45

From project jboss-as-quickstart, under directory /xml-dom4j/src/main/java/org/jboss/as/quickstart/xml/upload/.

Source file: FileUploadServlet.java

  21 
vote

@Override protected void doPost(HttpServletRequest req,HttpServletResponse resp) throws ServletException, IOException {
  final String reqContentType=req.getContentType();
  if (!reqContentType.contains("multipart/form-data")) {
    logger.severe("Received request which is not mulipart: " + reqContentType);
    resp.sendError(406,"Received request which is not mulipart: " + reqContentType);
    return;
  }
  Collection<Part> fileParts=req.getParts();
  if (fileParts != null && fileParts.size() > 0) {
    for (    Part p : fileParts) {
      String partContentType=p.getContentType();
      String partName=p.getName();
      if (partContentType != null && partContentType.equals("text/xml") && partName != null && partName.equals(INPUT_NAME)) {
        InputStream is=p.getInputStream();
        fileUploadBean.parseUpload(is);
        break;
      }
    }
  }
  RequestDispatcher rd=getServletContext().getRequestDispatcher("/");
  if (rd != null) {
    rd.forward(req,resp);
    return;
  }
 else {
    throw new IllegalStateException("Container is not well!");
  }
}
 

Example 46

From project jbpm-form-builder, under directory /jbpm-gwt-form-builder/src/test/java/org/jbpm/formbuilder/server/.

Source file: EmbedingServletTest.java

  21 
vote

public void testDoGetOK() throws Exception {
  String uuid=UUID.randomUUID().toString();
  HttpServletRequest request=EasyMock.createMock(HttpServletRequest.class);
  HttpServletResponse response=EasyMock.createMock(HttpServletResponse.class);
  EasyMock.expect(request.getParameter(EasyMock.eq("profile"))).andReturn("guvnor").once();
  EasyMock.expect(request.getParameter(EasyMock.eq("usr"))).andReturn(null).once();
  EasyMock.expect(request.getParameter(EasyMock.eq("pwd"))).andReturn(null).once();
  EasyMock.expect(request.getParameter(EasyMock.eq("uuid"))).andReturn(uuid).once();
  FormDefinitionService formService=EasyMock.createMock(FormDefinitionService.class);
  TaskDefinitionService taskService=EasyMock.createMock(TaskDefinitionService.class);
  EasyMock.expect(taskService.getContainingPackage(EasyMock.eq(uuid))).andReturn("somePackage").once();
  FormRepresentation form=RESTAbstractTest.createMockForm("myForm","my1Param","my2Param");
  EasyMock.expect(formService.getFormByUUID(EasyMock.eq("somePackage"),EasyMock.eq(uuid))).andReturn(form).once();
  request.setAttribute(EasyMock.eq("jsonData"),EasyMock.anyObject(String.class));
  EasyMock.expectLastCall().once();
  RequestDispatcher dispatcher=EasyMock.createMock(RequestDispatcher.class);
  dispatcher.forward(request,response);
  EasyMock.expectLastCall().once();
  EasyMock.expect(request.getRequestDispatcher(EasyMock.eq("/FormBuilder.jsp"))).andReturn(dispatcher);
  EmbedingServlet servlet=createServlet(formService,taskService);
  EasyMock.replay(request,response,formService,taskService,dispatcher);
  servlet.doGet(request,response);
  EasyMock.verify(request,response,formService,taskService,dispatcher);
}
 

Example 47

From project jsf-test, under directory /stage/src/main/java/org/jboss/test/faces/staging/.

Source file: StagingConnection.java

  21 
vote

@Override public RequestDispatcher getRequestDispatcher(String path){
  RequestDispatcher dispatcher=null;
  if (!path.startsWith("/")) {
    try {
      URL absoluteUrl=new URL(url,path);
      path=absoluteUrl.getFile();
    }
 catch (    MalformedURLException e) {
      return null;
    }
  }
  final RequestChain dispatchedServlet=server.getServlet(path);
  if (null != dispatchedServlet) {
    dispatcher=new RequestDispatcher(){
      public void forward(      ServletRequest request,      ServletResponse response) throws ServletException, IOException {
        response.reset();
        dispatchedServlet.execute(request,response);
      }
      public void include(      ServletRequest request,      ServletResponse response) throws ServletException, IOException {
        dispatchedServlet.execute(request,response);
      }
    }
;
  }
  return dispatcher;
}
 

Example 48

From project lime-mvc, under directory /src/org/zdevra/guice/mvc/views/.

Source file: JspView.java

  21 
vote

@Override public void render(ModelMap model,HttpServlet servlet,HttpServletRequest request,HttpServletResponse response){
  request=new HttpRequestForForward(request,jspPath);
  RequestDispatcher dispatcher=servlet.getServletContext().getRequestDispatcher(jspPath);
  if (dispatcher == null) {
    throw new InvalidJspViewException(jspPath);
  }
  try {
    dispatcher.forward(request,response);
  }
 catch (  ServletException e) {
    logger.log(Level.SEVERE,"Error in JspView",e);
  }
catch (  IOException e) {
    logger.log(Level.SEVERE,"Error in JspView",e);
  }
  request=null;
}
 

Example 49

From project nuxeo-filesystem-connectors, under directory /nuxeo-generic-wss-front/src/main/java/org/nuxeo/wss/servlet/.

Source file: BaseWSSFilter.java

  21 
vote

protected void handleWebDavCall(HttpServletRequest httpRequest,HttpServletResponse httpResponse) throws Exception {
  String destination=httpRequest.getHeader("Destination");
  if (StringUtils.isNotEmpty(destination)) {
    destination=resolveDestinationPath(destination);
    HttpServletRequestWrapper httpRequestWrapper=new HttpServletRequestWrapper(httpRequest);
    httpRequestWrapper.setHeader("destination",destination);
    httpRequest=httpRequestWrapper;
  }
  if (isMSWebDavRequest(httpRequest)) {
    httpResponse.setHeader("Server","Microsoft-IIS/6.0");
    httpResponse.setHeader("X-Powered-By","ASP.NET");
    httpResponse.setHeader("MicrosoftSharePointTeamServices","12.0.0.6421");
    httpResponse.setHeader("Content-Type","text/xml");
    httpResponse.setHeader("Cache-Control","no-cache");
    httpResponse.setHeader("Public-Extension","http://schemas.microsoft.com/repl-2");
  }
  String createdURL=createPathToWebDav(httpRequest.getRequestURI());
  RequestDispatcher dispatcher=ctx.getRequestDispatcher(createdURL);
  dispatcher.forward(httpRequest,httpResponse);
}
 

Example 50

From project nuxeo-jsf, under directory /nuxeo-platform-ui-web/src/main/java/org/nuxeo/ecm/platform/ui/web/rest/.

Source file: FancyURLFilter.java

  21 
vote

public void doFilter(ServletRequest request,ServletResponse response,FilterChain chain) throws IOException, ServletException {
  HttpServletRequest httpRequest=(HttpServletRequest)request;
  HttpServletResponse httpResponse=(HttpServletResponse)response;
  try {
    getUrlService();
    urlService.initViewIdManager(servletContext);
    if (urlService.isCandidateForDecoding(httpRequest)) {
      DocumentView docView=urlService.getDocumentViewFromRequest(httpRequest);
      if (docView != null) {
        urlService.setDocumentViewInRequest(httpRequest,docView);
        String jsfOutcome=docView.getViewId();
        String target=urlService.getViewIdFromOutcome(jsfOutcome,httpRequest);
        RequestDispatcher dispatcher;
        if (target != null) {
          dispatcher=httpRequest.getRequestDispatcher(target);
        }
 else {
          dispatcher=httpRequest.getRequestDispatcher("/malformed_url_error_page.faces");
        }
        request.setAttribute(URLPolicyService.FORCE_URL_ENCODING_REQUEST_KEY,Boolean.TRUE);
        dispatcher.forward(new FancyURLRequestWrapper(httpRequest,docView),wrapResponse(httpRequest,httpResponse));
        return;
      }
    }
    chain.doFilter(request,wrapResponse(httpRequest,httpResponse));
  }
 catch (  ServletException e) {
    throw e;
  }
catch (  Throwable t) {
    throw new ServletException(t);
  }
}
 

Example 51

From project org.ops4j.pax.web, under directory /pax-web-runtime/src/main/java/org/ops4j/pax/web/service/internal/.

Source file: WelcomeFilesFilter.java

  21 
vote

/** 
 * Serves the welcome files if request path ends with "/".
 * @see Filter#doFilter(ServletRequest,ServletResponse,FilterChain)
 */
public void doFilter(final ServletRequest request,final ServletResponse response,final FilterChain chain) throws IOException, ServletException {
  LOG.debug("Apply welcome files filter...");
  if (m_welcomeFiles.length > 0 && request instanceof HttpServletRequest) {
    String servletPath=(((HttpServletRequest)request).getServletPath());
    String pathInfo=((HttpServletRequest)request).getPathInfo();
    LOG.debug("Servlet path: " + servletPath);
    LOG.debug("Path info: " + pathInfo);
    if ((pathInfo != null && pathInfo.endsWith("/")) || (servletPath != null && servletPath.endsWith("/"))) {
      final ServletContext servletContext=m_filterConfig.getServletContext();
      for (      String welcomeFile : m_welcomeFiles) {
        final String welcomePath=addPaths(servletPath,addPaths(pathInfo,welcomeFile));
        final URL welcomeFileUrl=servletContext.getResource(welcomePath);
        if (welcomeFileUrl != null) {
          if (m_redirect && response instanceof HttpServletResponse) {
            ((HttpServletResponse)response).sendRedirect(welcomeFile);
            return;
          }
 else {
            final RequestDispatcher requestDispatcher=request.getRequestDispatcher(welcomePath);
            if (requestDispatcher != null) {
              requestDispatcher.forward(request,response);
              return;
            }
          }
        }
      }
    }
  }
 else {
    if (m_welcomeFiles.length == 0) {
      LOG.debug("Welcome filter not applied as there are no welcome files configured.");
    }
    if (!(request instanceof HttpServletRequest)) {
      LOG.debug("Welcome filter not applied as the request is not an " + HttpServletRequest.class.getSimpleName());
    }
  }
  chain.doFilter(request,response);
}
 

Example 52

From project serfj, under directory /src/main/java/net/sf/serfj/.

Source file: ResponseHelper.java

  21 
vote

protected void forward() throws IOException, ServletException {
  if (requestedPage == null || "".equals(requestedPage)) {
    throw new IOException("Page or Action doesn't exist");
  }
 else {
    try {
      request.setAttribute("identifiers",urlInfo.getIdentifiers());
      RequestDispatcher dispatcher=context.getRequestDispatcher(requestedPage);
      if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("Forwarding to {}",requestedPage);
      }
      dispatcher.forward(request,response);
    }
 catch (    ServletException e) {
      LOGGER.error(e.getLocalizedMessage(),e);
      throw e;
    }
  }
}
 

Example 53

From project sparsemapcontent, under directory /extensions/http/src/main/java/uk/co/tfd/sm/http/batch/.

Source file: BatchProcessor.java

  21 
vote

private boolean doRequest(HttpServletRequest request,HttpServletResponse response,RequestInfo requestInfo,JsonWriter write) throws ServletException, IOException {
  boolean cache=true;
  if (!"GET".equals(requestInfo.getMethod())) {
    cache=false;
    String user=request.getRemoteUser();
    if (user == null || user.length() == 0 || User.ANON_USER.equals(request.getRemoteUser())) {
      response.reset();
      throw new ServletException("Anon Users may only perform GET operations");
    }
  }
  String requestPath=requestInfo.getUrl();
  RequestWrapper requestWrapper=new RequestWrapper(request,requestInfo);
  ResponseWrapper responseWrapper=new ResponseWrapper(response);
  RequestDispatcher requestDispatcher;
  try {
    requestDispatcher=request.getRequestDispatcher(requestPath);
    requestDispatcher.forward(requestWrapper,responseWrapper);
    cache=writeResponse(write,responseWrapper,requestInfo) && cache;
  }
 catch (  ServletException e) {
    writeFailedRequest(write,requestInfo);
    cache=false;
  }
catch (  IOException e) {
    writeFailedRequest(write,requestInfo);
    cache=false;
  }
  return cache;
}
 

Example 54

From project usergrid-stack, under directory /standalone/src/main/java/org/usergrid/standalone/.

Source file: CustomJSPTemplateProcessor.java

  21 
vote

public String findJsp(String path) throws MalformedURLException {
  if (servletContext.getResource(path) != null) {
    return path;
  }
 else {
    ServletContext jspContext=servletContext.getContext(path);
    if (jspContext != null) {
      RequestDispatcher jspReqDispatcher=servletContext.getRequestDispatcher(path);
      if (jspReqDispatcher != null) {
        return path;
      }
    }
    RequestDispatcher reqDispatcher=servletContext.getRequestDispatcher(path);
    if (reqDispatcher != null) {
      return path;
    }
  }
  return null;
}
 

Example 55

From project waffle, under directory /Source/JNAWindowsAuthProvider/src/waffle/apache/.

Source file: MixedAuthenticator.java

  21 
vote

private void redirectTo(Request request,Response response,String url){
  try {
    _log.debug("redirecting to: " + url);
    ServletContext servletContext=context.getServletContext();
    RequestDispatcher disp=servletContext.getRequestDispatcher(url);
    disp.forward(request.getRequest(),response);
  }
 catch (  IOException e) {
    _log.error(e.getMessage());
    throw new RuntimeException(e);
  }
catch (  ServletException e) {
    _log.error(e.getMessage());
    throw new RuntimeException(e);
  }
}
 

Example 56

From project zengsource-mvc, under directory /src/src/main/java/org/zengsource/mvc/view/.

Source file: DispatchView.java

  21 
vote

@Override public void forward() throws MvcException {
  if (StringUtil.isBlank(this.page)) {
    throw new MvcException("No page specified!");
  }
  logger.info("Dispatching to " + this.page);
  RequestDispatcher dispatcher=getRequest().getRequestDispatcher(page);
  try {
    dispatcher.forward(getRequest(),getResponse());
  }
 catch (  ServletException e) {
    e.printStackTrace();
  }
catch (  IOException e) {
    e.printStackTrace();
  }
}
 

Example 57

From project virgo.snaps, under directory /org.eclipse.virgo.snaps.core/src/main/java/org/eclipse/virgo/snaps/core/internal/webapp/container/.

Source file: SnapHttpServletRequest.java

  20 
vote

/** 
 * {@inheritDoc}
 */
@Override public RequestDispatcher getRequestDispatcher(final String path){
  if (path.startsWith(HOST_PATH_PREFIX)) {
    String hostPath=path.substring(HOST_PATH_PREFIX.length());
    return super.getRequestDispatcher(hostPath);
  }
 else {
    return new RequestDispatcher(){
      public void forward(      ServletRequest request,      ServletResponse response) throws ServletException, IOException {
        requestRouter.forward(path,(HttpServletRequest)request,(HttpServletResponse)response);
      }
      public void include(      ServletRequest request,      ServletResponse response) throws ServletException, IOException {
        requestRouter.include(path,(HttpServletRequest)request,(HttpServletResponse)response);
      }
    }
;
  }
}
 

Example 58

From project 3Dto2DApplet, under directory /src/java/nl/dannyarends/www/http/.

Source file: Webserver.java

  19 
vote

public RequestDispatcher getRequestDispatcher(String urlpath){
  if (urlpath == null || urlpath.length() == 0 || urlpath.charAt(0) != '/')   return null;
  try {
    return new SimpleRequestDispatcher(urlpath);
  }
 catch (  NullPointerException npe) {
    return null;
  }
}
 

Example 59

From project cipango, under directory /cipango-server/src/main/java/org/cipango/server/sipapp/.

Source file: SipAppContext.java

  19 
vote

@Override public RequestDispatcher getNamedDispatcher(String name){
  if (_servletHandler != null) {
    SipServletHolder holder=_servletHandler.getHolder(name);
    if (holder != null)     return new SipDispatcher(SipAppContext.this,holder);
  }
  return super.getNamedDispatcher(name);
}
 

Example 60

From project IOCipherServer, under directory /src/Acme/Serve/.

Source file: Serve.java

  19 
vote

public RequestDispatcher getRequestDispatcher(String urlpath){
  if (urlpath == null || urlpath.length() == 0 || urlpath.charAt(0) != '/')   return null;
  try {
    return new SimpleRequestDispatcher(urlpath);
  }
 catch (  NullPointerException npe) {
    return null;
  }
}
 

Example 61

From project kernel_1, under directory /exo.kernel.container/src/main/java/org/exoplatform/container/.

Source file: PortalContainerContext.java

  19 
vote

/** 
 * {@inheritDoc}
 */
public RequestDispatcher getRequestDispatcher(String path){
  final WebAppInitContext[] contexts=getWebAppInitContexts();
  for (int i=contexts.length - 1; i >= 0; i--) {
    final ServletContext context=contexts[i].getServletContext();
    final InputStream is=context.getResourceAsStream(path);
    if (is != null) {
      return context.getRequestDispatcher(path);
    }
  }
  return null;
}
 

Example 62

From project mateo, under directory /src/test/java/mx/edu/um/mateo/general/test/.

Source file: GenericWebXmlContextLoader.java

  19 
vote

private MockServletContext initServletContext(String warRootDir,ResourceLoader resourceLoader){
  return new MockServletContext(warRootDir,resourceLoader){
    @Override public RequestDispatcher getNamedDispatcher(    String path){
      return (path.equals("default")) ? new MockRequestDispatcher(path) : super.getNamedDispatcher(path);
    }
  }
;
}
 

Example 63

From project spring-test-mvc, under directory /src/main/java/org/springframework/test/web/server/setup/.

Source file: ContextMockMvcBuilder.java

  19 
vote

@Override protected WebApplicationContext initWebApplicationContext(){
  ServletContext servletContext=new MockServletContext(this.webResourceBasePath,this.webResourceLoader){
    public RequestDispatcher getNamedDispatcher(    String path){
      return (path.equals("default")) ? new MockRequestDispatcher(path) : super.getNamedDispatcher(path);
    }
  }
;
  this.webAppContext.setServletContext(servletContext);
  this.webAppContext.refresh();
  return this.webAppContext;
}
 

Example 64

From project vraptor-vraptor2, under directory /src/test/java/br/com/caelum/vraptor/vraptor2/.

Source file: ViewsPropertiesPageResultTest.java

  19 
vote

@Before public void setup(){
  this.mockery=new Mockery();
  this.request=mockery.mock(MutableRequest.class);
  this.response=mockery.mock(MutableResponse.class);
  this.session=mockery.mock(HttpSession.class);
  this.method=mockery.mock(ResourceMethod.class);
  this.resource=mockery.mock(ResourceClass.class);
  this.config=mockery.mock(Config.class);
  this.resolver=mockery.mock(PathResolver.class);
  this.dispatcher=mockery.mock(RequestDispatcher.class);
  this.info=mockery.mock(MethodInfo.class);
  mockery.checking(new Expectations(){
{
      allowing(request).getParameterMap();
      will(returnValue(new HashMap<String,Object>()));
      allowing(request).getSession();
      will(returnValue(session));
      allowing(session).getAttribute("org.vraptor.scope.ScopeType_FLASH");
      will(returnValue(new HashMap<String,Object>()));
      allowing(info).getResourceMethod();
      will(returnValue(method));
      allowing(method).getResource();
      will(returnValue(resource));
      allowing(info).getResult();
      will(returnValue("ok"));
    }
  }
);
  FilterChain chain=mockery.mock(FilterChain.class);
  this.webRequest=new RequestInfo(context,chain,request,response);
  DefaultPageResult delegate=new DefaultPageResult(request,response,info,resolver,null);
  this.result=new ViewsPropertiesPageResult(this.config,this.resolver,this.info,this.webRequest,info,null,delegate);
}