Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * Copyright (c) SiteWhere, LLC. All rights reserved. http://www.sitewhere.com
  *
  * The software in this package is published under the terms of the CPAL v1.0
  * license, a copy of which has been included with this distribution in the
  * LICENSE.txt file.
  */
 package com.sitewhere.web;
 
Takes care of 404 caused by not including the trailing slash on the admin interface URL.

Author(s):
Derek
public class RedirectServlet extends HttpServlet {

Serial version UID
	private static final long serialVersionUID = -7603366944363905594L;
	/*
	 * (non-Javadoc)
	 * 
	 * @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest,
	 * javax.servlet.http.HttpServletResponse)
	 */
	public void doGet(HttpServletRequest requestHttpServletResponse responsethrows ServletException,
		response.setContentType("text/html");
		String url = request.getRequestURL().toString() + "/";
		response.setHeader("Location"url);
	}
New to GrepCode? Check out our FAQ X