Exemplo n.º 1
0
 @Override
 public void doFilter(ServletRequest request, ServletResponse response)
     throws IOException, ServletException {
   final HttpListenerRegistry registry =
       SystemInstance.get().getComponent(HttpListenerRegistry.class);
   registry.setOrigin(origin);
   try {
     registry.onMessage(
         HttpRequest.class.isInstance(request)
             ? HttpRequest.class.cast(request)
             : new ServletRequestAdapter(HttpServletRequest.class.cast(request)),
         HttpResponse.class.isInstance(response)
             ? HttpResponse.class.cast(response)
             : new ServletResponseAdapter(HttpServletResponse.class.cast(response)));
   } catch (final RuntimeException re) {
     throw re;
   } catch (final ServletException e) {
     final Throwable cause = e.getCause();
     if (RuntimeException.class.isInstance(
         cause)) { // frameworks generally wrap with ServletException
       throw RuntimeException.class.cast(cause);
     }
     throw e;
   } catch (final IOException e) {
     throw e;
   } catch (final Exception e) {
     throw new ServletException(e);
   } finally {
     registry.setOrigin(origin);
   }
 }
Exemplo n.º 2
0
  public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) {
    HttpServletRequest req = (HttpServletRequest) request;
    HttpServletResponse rpo = (HttpServletResponse) response;
    javax.servlet.http.HttpSession session = req.getSession();

    try {
      req.setCharacterEncoding("utf-8");
    } catch (Exception e1) {
      e1.printStackTrace();
    }
    String userId = (String) session.getAttribute("username");
    if (userId != null) {
      try {
        chain.doFilter(request, response);
      } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      } catch (ServletException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    } else {
      try {
        response.setCharacterEncoding("utf-8");
        PrintWriter out = response.getWriter();
        out.print("{'success':false,'msg':'未登录或登录失效'}");
        out.flush();
        out.close();
        // rpo.sendRedirect("/login.jsp");
      } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }
  }
Exemplo n.º 3
0
  public ReturnStatus login(String Auth, HttpServletRequest req, HttpSession session) {

    System.out.println("login");

    String[] result = decodeToken(Auth);
    System.out.println("login, result = " + result[0]);

    if (result[0].equals("OK")) {

      System.out.println("login : "******" / password = "******"user", req.getRemoteUser());
        } catch (ServletException e) {
          System.out.println("login ServletException");
          return new ReturnStatus(false, "login ServletException" + e.getMessage());
        }
        System.out.println("Login OK, remoteuser = "******"login, RequestedSessionId = " + req.getRequestedSessionId());

        System.out.println("Login OK");
        return new ReturnStatus(true, getroles(result[1]));
      } else {
        System.out.println("user niet gevonden (null)");
        return new ReturnStatus(false, "user niet gevonden (null)");
      }
    } else {
      System.out.println("invalid");
      return new ReturnStatus(false, result[1]);
    }
  }
Exemplo n.º 4
0
  @Override
  public JsonObject getJson() {
    if (json == null) {
      boolean isMultiPart = true;
      try {
        getParts();
      } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      } catch (ServletException e) {
        logger.fatal("The request was not multipart, " + e.getMessage());
        isMultiPart = false;
      }

      if (!isMultiPart) {
        try {
          json = JsonUtils.getJsonRequest(this);
          return json;
        } catch (Exception e) {
          logger.debug("No json body associated with this request, {}", e.getMessage());
        }
      }

      try {
        json = JsonUtils.getJsonFromField(this);
        return json;
      } catch (JsonException e) {
        logger.debug("No json field associated with this request, {}", e.getMessage());
      }

      json = new JsonObject();
    }

    return json;
  }
  public void handleParseStart(ParseContext pContext) throws IOException {

    ReplayParseContext context = (ReplayParseContext) pContext;

    String policy = context.getJspExec().getUiResults().getResult().getOraclePolicy();

    if (policy != null) {
      context.setOraclePolicy(policy);
    }

    if (startJsp != null) {
      OutputStream out = context.getOutputStream();
      String tmp = null;
      try {
        tmp = context.getJspExec().jspToString(startJsp);
      } catch (ServletException e) {
        e.printStackTrace();
      }
      if (tmp != null) {
        //				Charset charset = Charset.forName(context.getOutputCharset());
        String charset = context.getOutputCharset();
        out.write(tmp.getBytes(charset));
      }
    }
  }
Exemplo n.º 6
0
  /** Retrieve {@link com.opensymphony.module.sitemesh.Decorator} based on 'pattern' tag. */
  public Decorator getDecorator(HttpServletRequest request, Page page) {
    String thisPath = request.getServletPath();

    // getServletPath() returns null unless the mapping corresponds to a servlet
    if (thisPath == null) {
      String requestURI = request.getRequestURI();
      if (request.getPathInfo() != null) {
        // strip the pathInfo from the requestURI
        thisPath = requestURI.substring(0, requestURI.indexOf(request.getPathInfo()));
      } else {
        thisPath = requestURI;
      }
    } else if ("".equals(thisPath)) {
      // in servlet 2.4, if a request is mapped to '/*', getServletPath returns null (SIM-130)
      thisPath = request.getPathInfo();
    }

    String name = null;
    try {
      name = configLoader.getMappedName(thisPath);
    } catch (ServletException e) {
      e.printStackTrace();
    }

    Decorator result = getNamedDecorator(request, name);
    return result == null ? super.getDecorator(request, page) : result;
  }
Exemplo n.º 7
0
 @RequestMapping(value = "/autologin/user", method = RequestMethod.GET)
 public @ResponseBody ResponseEntity<Map<String, Object>> autologin1(HttpServletRequest request) {
   Map<String, Object> map = new HashMap<String, Object>();
   HttpStatus status = null;
   try {
     request.login("author", "1");
     map.put("MESSAGE", "AUTO LOG IN SUCCESS WITH DEFAULT AUTHOR ACCOUNT 'author'");
     map.put("STATUS", "200");
     map.put("IS_LOGIN", isAuthenticated());
     map.put("ROLE", getRole());
     map.put("USERNAME", getUsername());
     status = HttpStatus.OK;
   } catch (ServletException e) {
     // TODO Auto-generated catch block
     map.put("MESSAGE", e.getMessage());
     map.put("IS_LOGIN", isAuthenticated());
     map.put("ROLE", getRole());
     map.put("USERNAME", getUsername());
     status = HttpStatus.BAD_REQUEST;
     e.printStackTrace();
     return new ResponseEntity<Map<String, Object>>(map, status);
   }
   System.out.println(isAuthenticated());
   System.out.println(getRole());
   System.out.println(getUsername());
   return new ResponseEntity<Map<String, Object>>(map, status);
 }
  public void processrequest(HttpServletRequest request, HttpServletResponse response)
      throws IOException, ServletException {

    try {
      boolean multi = isMultipartRequest(request);
      String svg = getParameter(request, "svg", multi);
      if (svg == null || svg.isEmpty()) {
        throw new ServletException("The required - svg - post parameter is missing");
      }

      if (svg.indexOf(FORBIDDEN_WORD) > -1 || svg.indexOf(FORBIDDEN_WORD.toLowerCase()) > -1) {
        throw new ServletException("The - svg - post parameter could contain a malicious attack");
      }

      String filename = getFilename(getParameter(request, "filename", multi));
      Float width = getWidth(getParameter(request, "width", multi));
      MimeType mime = getMime(getParameter(request, "type", multi));

      ExportController.writeFileContentToHttpResponse(svg, filename, width, mime, response);

    } catch (IOException ioe) {
      logger.error("Oops something happened here redirect to error-page, " + ioe.getMessage());
      sendError(request, response, ioe);
    } catch (ServletException sce) {
      logger.error("Oops something happened here redirect to error-page, " + sce.getMessage());
      sendError(request, response, sce);
    }
  }
Exemplo n.º 9
0
  public void doGet(HttpServletRequest req, HttpServletResponse res) {
    res.setContentType("application/download-xml-file");

    String messageId = req.getParameter("message");

    OMElement report = null;

    try {
      Message m = new Message(messageId);
      m.readMessage();

      report = buildReport(m);

    } catch (LoggerException e) {
      report = omFactory.createOMElement(new QName("NoReportAvailable"));
      report.setText(e.getMessage().replaceAll("<", "&lt;"));
    } catch (ServletException e) {
      report = omFactory.createOMElement(new QName("NoReportAvailable"));
      report.setText(e.getMessage().replaceAll("<", "&lt;"));
    }

    try {
      res.getWriter().write(report.toString());
    } catch (IOException e) {
    }
  }
  /**
   * Redirect the request to another page if the user is a Monitor type and the discrepancy note is
   * a type other than item data or event crf.
   *
   * @param module A String like "managestudy" or "admin"
   * @param discrepancyNoteBean
   */
  private void redirectMonitor(String module, DiscrepancyNoteBean discrepancyNoteBean) {

    if (discrepancyNoteBean != null) {

      String createNoteURL = "";
      // This String will determine whether the type is other than
      // itemdata.
      String entityType = discrepancyNoteBean.getEntityType().toLowerCase();
      // The id of the subject, study subject, or study event
      int entityId = discrepancyNoteBean.getEntityId();
      RequestDispatcher dispatcher = null;
      DiscrepancyNoteUtil discNoteUtil = new DiscrepancyNoteUtil();

      if (entityType != null
          && !"".equalsIgnoreCase(entityType)
          && !"itemdata".equalsIgnoreCase(entityType)
          && !"eventcrf".equalsIgnoreCase(entityType)) {
        // redirect to View Study Subject
        // addPageMessage(resword.getString("monitors_do_not_have_permission_to_resolve_discrepancy_notes"));
        if ("studySub".equalsIgnoreCase(entityType)) {
          dispatcher =
              request.getRequestDispatcher(
                  "/ViewStudySubject?id=" + entityId + "&module=" + module);
          discrepancyNoteBean.setSubjectId(entityId);
        } else if ("subject".equalsIgnoreCase(entityType)) {

          int studySubId =
              discNoteUtil.getStudySubjectIdForDiscNote(
                  discrepancyNoteBean, sm.getDataSource(), currentStudy.getId());

          dispatcher =
              request.getRequestDispatcher(
                  "/ViewStudySubject?id=" + studySubId + "&module=" + module);
          discrepancyNoteBean.setSubjectId(studySubId);
        } else if ("studyevent".equalsIgnoreCase(entityType)) {
          dispatcher = request.getRequestDispatcher("/EnterDataForStudyEvent?eventId=" + entityId);
        }

        // This code creates the URL for a popup window, which the
        // processing Servlet will initiate.
        // 'true' parameter means that ViewDiscrepancyNote is the
        // handling Servlet.
        createNoteURL =
            CreateDiscrepancyNoteServlet.getAddChildURL(
                discrepancyNoteBean, ResolutionStatus.CLOSED, true);
        request.setAttribute(POP_UP_URL, createNoteURL);

        try {
          if (dispatcher != null) {
            dispatcher.forward(request, response);
          }
        } catch (ServletException e) {
          e.printStackTrace();
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
    }
  }
 public void init(final ServletConfig sc) {
   try {
     super.init(sc);
   } catch (ServletException e) {
     e.printStackTrace();
   }
   PersistenceUtils.init(sc);
 }
Exemplo n.º 12
0
 public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
   try {
     doPost(request, response);
   } catch (ServletException e) {
     e.printStackTrace();
     request.setAttribute("pushStatus", e.toString());
   }
 }
 public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
   try {
     request.getRequestDispatcher("/jsp/welcome.jsp").forward(request, response);
     return;
   } catch (ServletException e) {
     e.printStackTrace();
   }
 }
Exemplo n.º 14
0
 /**
  * 请求转发
  *
  * @param url 转发地址
  */
 public void forward(String url) {
   try {
     this.request.getRequestDispatcher(url).forward(request, response);
   } catch (ServletException e) {
     e.printStackTrace();
   } catch (IOException e) {
     e.printStackTrace();
   }
 }
Exemplo n.º 15
0
  public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
      throws IOException, ServletException {
    if (!(request instanceof HttpServletRequest)) {
      chain.doFilter(request, response);
      return;
    }

    HttpServletRequest httpRequest = (HttpServletRequest) request;

    boolean isMultipartContent = FileUpload.isMultipartContent(httpRequest);
    if (!isMultipartContent) {
      chain.doFilter(request, response);
      return;
    }

    DiskFileUpload upload = new DiskFileUpload();
    if (repositoryPath != null) upload.setRepositoryPath(repositoryPath);

    try {
      List list = upload.parseRequest(httpRequest);
      final Map map = new HashMap();
      for (int i = 0; i < list.size(); i++) {
        FileItem item = (FileItem) list.get(i);
        String str = item.getString();
        if (item.isFormField()) map.put(item.getFieldName(), new String[] {str});
        else httpRequest.setAttribute(item.getFieldName(), item);
      }

      chain.doFilter(
          new HttpServletRequestWrapper(httpRequest) {
            public Map getParameterMap() {
              return map;
            }

            public String[] getParameterValues(String name) {
              Map map = getParameterMap();
              return (String[]) map.get(name);
            }

            public String getParameter(String name) {
              String[] params = getParameterValues(name);
              if (params == null) return null;
              return params[0];
            }

            public Enumeration getParameterNames() {
              Map map = getParameterMap();
              return Collections.enumeration(map.keySet());
            }
          },
          response);
    } catch (FileUploadException ex) {
      ServletException servletEx = new ServletException();
      servletEx.initCause(ex);
      throw servletEx;
    }
  }
Exemplo n.º 16
0
 public void valueUnbound(HttpSessionBindingEvent be) {
   if (be.getName().equals("Session")) {
     try {
       cleanUp(); // remove references in hash right away (this method is synchronized)
     } catch (ServletException ex) {
       dbgApp("ServletException: " + ex.getMessage());
     }
   }
 }
Exemplo n.º 17
0
  @SuppressWarnings("unchecked")
  @Override
  public void doPost(HttpServletRequest req, HttpServletResponse resp)
      throws IOException, ServletException {
    List<String> errors = new ArrayList<String>();
    PersistenceManager pm = getPersistenceManager();
    String username = req.getParameter("username");
    String password = req.getParameter("password");

    if (username.isEmpty()) {
      errors.add("Username is required.");
    }
    if (password.isEmpty()) {
      errors.add("Password is required.");
    }

    try {
      req.setAttribute("errors", errors);
      List<Admin> us = (List<Admin>) pm.newQuery(Admin.class).execute();

      resp.setContentType("text/html");

      DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
      Query q = new Query("Admin");
      q.setFilter(
          Query.CompositeFilterOperator.and(
              new Query.FilterPredicate("username", Query.FilterOperator.EQUAL, username),
              new Query.FilterPredicate("password", Query.FilterOperator.EQUAL, password)));
      List<Entity> entities = ds.prepare(q).asList(FetchOptions.Builder.withDefaults());
      if (entities.size() == 0) {
        req.getRequestDispatcher("/login.jsp").forward(req, resp);
      }
      // if(entities.size()>0){
      if (us.size() > 0) {
        /*for(int i = 0; i < us.size(); i++){
        	if(us.get(i).getPassword().equals(password) && us.get(i).getUsername().equals(username) && us.get(i).getUser_type() == 0){
        		resp.sendRedirect("/AdminHome");
        	}
        	if(us.get(i).getPassword().equals(password) && us.get(i).getUsername().equals(username) && us.get(i).getUser_type() == 1){
        		resp.sendRedirect("/login.jsp");
        	}
        	if(us.get(i).getPassword().equals(password) && us.get(i).getUsername().equals(username) && us.get(i).getUser_type() == 2){
        		resp.sendRedirect("/login.jsp");
        	}
        }
        //resp.sendRedirect("/login.jsp");
         *
         */
        //	}
      }
    } catch (ServletException e) {
      e.printStackTrace();
    } finally {
      pm.close();
    }
  }
Exemplo n.º 18
0
 public void forward(HttpServletRequest request, HttpServletResponse respone) {
   request.setAttribute("redirectUrl", Constant.ROOT_URL + "loginController.do?login");
   try {
     request.getRequestDispatcher("/webpage/common/loginTimeout.jsp").forward(request, respone);
   } catch (ServletException e) {
     e.printStackTrace();
   } catch (IOException e) {
     e.printStackTrace();
   }
 }
  private void initServices(ServletContext context) throws ServletException {

    // get list of OGC services
    String serviceList = this.getRequiredInitParameter(SERVICE);

    String[] serviceNames = StringTools.toArray(serviceList, ",", false);

    ServiceLookup lookup = ServiceLookup.getInstance();
    for (int i = 0; i < serviceNames.length; i++) {
      LOG.logInfo(
          StringTools.concat(100, "---- Initializing ", serviceNames[i].toUpperCase(), " ----"));
      try {
        String className = this.getRequiredInitParameter(serviceNames[i] + HANDLER_CLASS);
        Class<?> handlerClzz = Class.forName(className);

        // initialize each service factory
        String s = this.getRequiredInitParameter(serviceNames[i] + HANDLER_CONF);
        URL serviceConfigurationURL = WebappResourceResolver.resolveFileLocation(s, context, LOG);

        // set configuration
        LOG.logInfo(
            StringTools.concat(
                300,
                "Reading configuration for ",
                serviceNames[i].toUpperCase(),
                " from URL: '",
                serviceConfigurationURL,
                "'."));

        String factoryClassName = SERVICE_FACTORIES_MAPPINGS.get(handlerClzz);

        Class<?> factory = Class.forName(factoryClassName);
        Method method = factory.getMethod("setConfiguration", new Class[] {URL.class});
        method.invoke(factory, new Object[] {serviceConfigurationURL});

        // The csw-ebrim profile adds an alternative service name, it too is registred with the CSW
        // handler.
        if ("CSW".equals(serviceNames[i].toUpperCase())) {
          lookup.addService(OGCRequestFactory.CSW_SERVICE_NAME_EBRIM.toUpperCase(), handlerClzz);
        }
        // put handler to available service list
        lookup.addService(serviceNames[i].toUpperCase(), handlerClzz);

        LOG.logInfo(
            StringTools.concat(300, serviceNames[i].toUpperCase(), " successfully initialized."));
      } catch (ServletException e) {
        LOG.logError(e.getMessage(), e);
      } catch (InvocationTargetException e) {
        e.getTargetException().printStackTrace();
        LOG.logError(this.produceMessage(ERR_MSG, new Object[] {serviceNames[i]}), e);
      } catch (Exception e) {
        LOG.logError("Can't initialize OGC service:" + serviceNames[i], e);
      }
    }
  }
 private void EnableDisableHandler(HttpServletRequest request, HttpServletResponse response) {
   try {
     forward("/EnableDisable.jsp", request, response);
   } catch (ServletException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   } catch (IOException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
 }
 /** sets to data the root tree */
 public void setRootTree() {
   try {
     data = ModuleReferenceDataClientTreeData.select(conn, (lang.equals("") ? "en_US" : lang));
     // addLinks();
     setLevel(0);
     setIcons();
   } catch (ServletException ex) {
     ex.printStackTrace();
     data = null;
   }
 }
 private void SearchCompanyHandler(HttpServletRequest request, HttpServletResponse response) {
   try {
     forward("/CompanySearchForm.jsp", request, response);
   } catch (ServletException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   } catch (IOException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
 }
Exemplo n.º 23
0
  public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {

    String fowarding = "/guestbook";
    RequestDispatcher rd = req.getRequestDispatcher(fowarding);

    try {
      rd.forward(req, resp);
    } catch (ServletException e) {
      e.printStackTrace();
    }
  }
Exemplo n.º 24
0
 public Collection<Part> parts() {
   try {
     return raw.getParts();
   } catch (IOException ex) {
     ex.printStackTrace();
     return null;
   } catch (ServletException ex) {
     ex.printStackTrace();
     return null;
   }
 }
Exemplo n.º 25
0
 public Part part(String name) {
   try {
     return raw.getPart(name);
   } catch (IOException ex) {
     ex.printStackTrace();
     return null;
   } catch (ServletException ex) {
     ex.printStackTrace();
     return null;
   }
 }
Exemplo n.º 26
0
  protected void activate() {
    try {
      logger.debug("Starting up proxy servlet at /" + PROXY_ALIAS);

      Hashtable<String, String> props = new Hashtable<String, String>();
      httpService.registerServlet("/" + PROXY_ALIAS, this, props, createHttpContext());
    } catch (NamespaceException e) {
      logger.error("Error during servlet startup: {}", e.getMessage());
    } catch (ServletException e) {
      logger.error("Error during servlet startup: {}", e.getMessage());
    }
  }
  public void process(HttpServletRequest request, HttpServletResponse response) {
    HttpSession session = request.getSession();
    ServletContext app = getServletContext();

    String lang = (String) app.getAttribute("MALL_LA");
    System.out.println("langl: " + lang);
    try {
      final String reasonSelect = request.getParameter("reasonSelect");
      final String reasonText = request.getParameter("reasonText");
      final String orderDetailID = request.getParameter("orderDetailID");
      // save cancel order
      if (orderDetailID != null) {
        TransactionMethod tr =
            new TransactionMethod() {
              @Override
              protected void doMethod(Session session, String lang) {

                Productorderdetail productorderdetail =
                    ProductorderdetailBUS.getProductorderdetail(
                        Integer.parseInt(orderDetailID), lang);
                System.out.println("lang: " + lang);
                // System.out.println("productorderdetail:
                // "+productorderdetail.getOrderDetailStatusId());
                productorderdetail.setOrderDetailStatusId(ResourcesDefault.ODS_RETURN_EXCHANGE);
                // System.out.println("productorderdetail:
                // "+productorderdetail.getOrderDetailStatusId());
                update(productorderdetail, session);

                Exchangeorder exchangeorder = new Exchangeorder();
                exchangeorder.setMemoToSeller(reasonText);
                exchangeorder.setReason(reasonSelect);
                exchangeorder.setOrderDetail(productorderdetail);
                Exchangestatus exchangStatus = ExchangeStatusBUS.getExchangeStatus(1, lang);
                exchangeorder.setExchangeStatus(exchangStatus);
                exchangeorder.setRequiredDate(new Date());

                save(exchangeorder, session);
              }
            };
        System.out.println("langL " + lang);
        boolean result = tr.executeTransaction(lang);
        if (result) {
          request.setAttribute("sucessfull", "successfull");
        }
        request.getRequestDispatcher("returnexchangesuccessfull.html").forward(request, response);
      }

    } catch (ServletException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
Exemplo n.º 28
0
  public void index(ServletRequest request, ServletResponse response) {
    try {

      request.setAttribute("page", "album");
      request.getRequestDispatcher("pages/album.jsp").forward(request, response);

    } catch (ServletException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
 public void emit(ReplayParseContext context, Node node) throws IOException {
   String found = context.getData(FERRET_DONE_KEY);
   if (found == null) {
     context.putData(FERRET_DONE_KEY, "1");
     try {
       super.emit(context, node);
     } catch (ServletException e) {
       e.printStackTrace();
       throw new IOException(e.getMessage());
     }
   }
 }
Exemplo n.º 30
0
	protected void sendRedirect(HttpServletRequest request,
			HttpServletResponse response, String targetUrl,
			boolean http10Compatible,boolean isforward,boolean isinclude) throws IOException {

		if(isloopredirect(request,
				targetUrl))
		{
			response.sendError(HttpServletResponse.SC_FORBIDDEN);
			return;
		}
		if(!isforward)
		{
			
			targetUrl = appendDTokenToTargetURL(request, targetUrl);
			if(!isinclude)
			{
				if (http10Compatible) {
					// Always send status code 302.
					response.sendRedirect(response.encodeRedirectURL(targetUrl));
				} else {
					// Correct HTTP status code is 303, in particular for POST requests.
					response.setStatus(303);
					response.setHeader("Location", response
							.encodeRedirectURL(targetUrl));
				}
			}
			else
			{
				 try
					{
						request.getRequestDispatcher(targetUrl).include(request, response);
					}
					catch (ServletException e)
					{
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
			}
		}
		else
		{
			 try
			{
				request.getRequestDispatcher(targetUrl).forward(request, response);
			}
			catch (ServletException e)
			{
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}