views:

35

answers:

2

I have next from:

<form action="relogin.jsp" method="post">
  <input type="text" id="authname" name="login" value="<%=login%>" tabindex="1" title="<%=bundle.getString("[Login]")%>" /> 
  <input type="password" name="pwd" id="authpass" value="" tabindex="2"  title="<%=bundle.getString("[Password]")%>" />
  <input type="submit" name="enter" value="<%=bundle.getString("[Enter]")%>" class="proaction" tabindex="3" title="<%=bundle.getString("[Enter]")%>" />
</form>

I maintain parameters in my jsp file:

<%if (request.getContentLength() == 0) { .[IE6,7 goes here]. } else { .[Chrome and FireFox goes here]. } %>

As you can see I have a problem to maintain post parameters posted form IE6,7. In Chrome and FireFox everything works fine. I use Apache Tomcat and log file doesn't contain any errors in both cases.

Any suggestions?

A: 

I just tried this and could not replicate the issue (I tested in FF4 Beta, IE6 and IE8):

    <% out.print("Content Length: " + request.getContentLength());%>
    <h1>Content Length Test</h1>

    <form action="test.jsp" method="post">
      <input type="text" id="authname" name="login" value="a" tabindex="1" title="" />
      <input type="password" name="pwd" id="authpass" value="b" tabindex="2"  title="" />
      <input type="submit" name="enter" value="b" class="proaction" tabindex="3" title="" />
    </form>

Can you try:

<%if (request.getContentLength() > 0) { .. } else { .[Chrome and FireFox goes here], [IE6,7 should go here]. } %>

Note: I also just tested in Chrome.. all browsers handle return the same value in request.getContentLength().. are you sure you are calling the function getContentLength on relogin.jsp ?

I used your example and still have the same problem. It prints "Content Length: 0" in IE 6,7 and values>0 in FF and Chrome.Here is example I used:<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> </head> <body> [your example] </body> </html>
Xupypr MV
Hmmm... i deploy this jsp to tomcat on you own computer and everything works fine, so as you said. The productive configuration is: Win 2003 server SP1, Apache Tomcat 5.5.20 , JVM 1.6.0_20.I think I have some problems with tomcat. Any ideas?
Xupypr MV
What configuration (OS, JVM, Tomcat) you have?
Xupypr MV
A: 

I am not sure then, maybe try a test page on your production server without request.getContentLength().. add a page with:

<%@page contentType="text/html" pageEncoding="UTF-8" import="java.io.*, java.util.*"%>

// adapted from: http://www.java2s.com/Code/Java/JSP/Printtherequestheadersandthesessionattributes.htm
   Enumeration enames = request.getHeaderNames();
   Enumeration pnames = request.getParameterNames();
   Map map = new TreeMap();

   while (enames.hasMoreElements()) {
      String name = (String) enames.nextElement();
      String value = request.getHeader(name);
      map.put(name, value);
   }
   while(pnames.hasMoreElements()) {
      String name = (String) pnames.nextElement();
      String value = request.getParameter(name);
      map.put(name, value);
    }

    out.println(createTable(map, "Request Headers"));

With:

   private static String createTable(Map map, String title)
  {
  StringBuffer sb = new StringBuffer();

  // Generate the header lines

  sb.append("<table border='1' cellpadding='3'>");
  sb.append("<tr>");
  sb.append("<th colspan='2'>");
  sb.append(title);
  sb.append("</th>");
  sb.append("</tr>");

  // Generate the table rows

  Iterator imap = map.entrySet().iterator();
  while (imap.hasNext()) {
     Map.Entry entry = (Map.Entry) imap.next();
     String key = (String) entry.getKey();
     String value = (String) entry.getValue();
     sb.append("<tr>");
     sb.append("<td>");
     sb.append(key);
     sb.append("</td>");
     sb.append("<td>");
     sb.append(value);
     sb.append("</td>");
     sb.append("</tr>");
  }

  // Generate the footer lines

  sb.append("</table><p></p>");

  // Return the generated HTML

  return sb.toString();

}

To see what headers the production server is returning.

Chrome:accept application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5accept-charset windows-1251,utf-8;q=0.7,*;q=0.3accept-encoding gzip,deflate,sdchaccept-language ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4cache-control max-age=0connection keep-alivecontent-length 27content-type application/x-www-form-urlencodedcookie ITEMS_PER_PAGE=10; selectedLocale=ru; JSESSIONID=131935136616541FC92889E4E2C38116enter blogin aasfpwd basf
Xupypr MV
IE:accept image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, \*/\* accept-encoding gzip, deflate accept-language ru authorization NTLM TlRMTVNTUAABAAAAB4IIogAAAAAAAAAAAAAAAAAAAAAFAs4OAAAAD2== cache-control no-cache connection Keep-Alive content-length 0 content-type application/x-www-form-urlencoded cookie JSESSIONID=65314A008A7B82B5DD33BE6939CA0D23
Xupypr MV
Do you have a proxy server configured in IE? (I ask because authorization NTLM).Maybe that is causing the issue?
Yes, i use proxy, but it's intranet connection, so i'm connecting avoid proxy.
Xupypr MV
I was wrong. IE wasn't setuped to avid proxy and proxy brokes my requests.
Xupypr MV
did you fix it?
Hmmm... problem was harder then i think. Proxy settings in IE is right.I use NTLM authentication in my application and want users can relogin. So I add relogin page but it's not worked in IE (i think it's because it saved some information about previous NTLM settings).
Xupypr MV
Bingo! The problem is solved. I create filter to remove "Authorization" header.
Xupypr MV