By checking the referer, the new page can see where the request came from. Referer logging is used to allow websites and web servers to identify where people are visiting them from, for promotional or security purposes.
String Refer = (String)req.getHeader("Referer"); ResourceBundle rBHttpReffer=ResourceBundle.getBundle("TIPS_Application"); if(Refer == null){ url = "Error.jsp"; }else { String subStrPro = rBHttpReffer.getString("HTTP_REFERER"); String sizeReferer = rBHttpReffer.getString("SIZE_REFERER"); StringBuffer sb = new StringBuffer(Refer); String subStr = sb.substring(0,Integer.parseInt(sizeReferer)); if(!subStrPro.equals(subStr)){ url = "Error.jsp"; }else{ // remaining code }