Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * Copyright © 2012 jbundle.org. All rights reserved.
  */
 package org.jbundle.util.webapp.redirect;

:
#)DBServlet.java 0.00 12-Feb-97 Don Corley Copyright © 2012 tourapp.com. All Rights Reserved. don@tourgeek.com
RedirectServlet This servlet is the redirect servlet.
public class RedirectServlet extends BaseOsgiServlet
	private static final long serialVersionUID = 1L;
	public static final String MATCH =  + "match";
	public static final String TARGET =  + "target";

returns the servlet info
 
    public String getServletInfo()
    {
        return "This the base servlet";
    }
    
init method.

Throws:
ServletException From inherited class.
    public void init(ServletConfig configthrows ServletException
    {
        super.init(config);
    }
    
Destroy this Servlet and any active applications. This is only called when all users are done using this Servlet.
    public void destroy()
    {
        super.destroy();
    }
    
process an HTML get or post.

Throws:
ServletException From inherited class.
IOException From inherited class.
    public void service(HttpServletRequest reqHttpServletResponse res
        throws ServletExceptionIOException
    {
        String browser = this.getBrowser(req);
        String queryString = req.getQueryString();
        String path = req.getPathInfo();
        if (path == null)
        	path = "";
        String target = this.getProperty(browser);
        if (target == null)
            target = this.getProperty();
        if (target == null)
            target = req.getParameter();
        if (queryString != null)
        {
            char delimiter = '?';
            if (target.indexOf('?') != -1)
                delimiter = '&';
            target = target + delimiter + queryString;
        }
        if ( != null)
        	.info("Redirect to " + target);
        String match = this.getProperty();
        if ((target != null) && ((match == null) || path.matches(match)))
        	res.sendRedirect(target);
        else
        	super.service(reqres);
    }
New to GrepCode? Check out our FAQ X