john pfeiffer
  • Home
  • Categories
  • Tags
  • Archives

jsp login ip forwarded

<?xml version="1.0" encoding="UTF-8" ?>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Login</title>
</head>
<body>
<%
    String remoteIPAddress = request.getHeader("X_FORWARDED_FOR");
    if( remoteIPAddress != null )       //is proxied
    {
        int addressDelimiter = remoteIPAddress.indexOf( ',' );
        if( addressDelimiter > -1)
        {
            remoteIPAddress = remoteIPAddress.substring( 0 , addressDelimiter );
    }
    }
    if( remoteIPAddress == null )
    {
        remoteIPAddress = request.getRemoteAddr();
    }
    out.println( remoteIPAddress );
%>
    <form id='login' action='LoginServlet' method="post"
        onsubmit="return isEmpty()">
        <div>
            Username:<input type='text' id='userName' name='userName' />
        </div>
        <div>
            Password:<input type='password' id='userPassword' name='userPassword' />
        </div>
        <div>
            <input type='submit' name='submit' value='submit' />
        </div>
    </form>



    <script type='text/javascript' src="<% request.getContextPath(); %>/javascript.js"></script>


    <script type='text/javascript'>
        setFocus("userName");
    </script>

</body>
</html>

  • « drupal 09 google analytics statistics read counter
  • eclipse maven runnable jar including dependencies eclipse hotkey »

Published

Aug 20, 2012

Category

java-servlet

~95 words

Tags

  • forwarded 1
  • ip 8
  • java-servlet 61
  • jsp 5
  • login 11