• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

redirect problem

 
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Folks,
Having a bit of a problem and I'm hoping someone can help.
I'm using response.sendRedirect to bring me into my application (which is using Struts).
If I go in directly there is no bother. However when I use the redirect and submit the first page all of my fields return nulls.
Has anyone seen this kind of behaviour before?
Regards,
Barry
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Barry, I tried to duplicate what I understand your problem to be:
1) index.jsp calls

2) index2.jsp has a form - I enter values and click submit. I have the action-mapping send the call back to index2.jsp
3) I see the values I previously entered, as expected.
No problems. How is your procedure different that it gives you the null values?
[ February 23, 2004: Message edited by: Marc Peabody ]
 
Barry Higgins
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Marc,
Thanks for your reply. The reason I'm using a redirect is because the first page gets the user's NT login name and passes this onto the next as a session variable. I found this code on the web!
package ntlm;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.net.*;
import javax.xml.parsers.*;
import org.w3c.dom.*;
import org.xml.sax.*;
public class UserAuthentication extends HttpServlet
{
public static String getUserName(HttpServletRequest request,
HttpServletResponse response)
{
String user="";
try
{
String auth=request.getHeader("Authorization");
if (auth==null)
{
response.setStatus(response.SC_UNAUTHORIZED);
response.setHeader("WWW-Authenticate", "NTLM");
response.flushBuffer();
return "";
}
if (auth.startsWith("NTLM "))
{
byte[] msg = new sun.misc.BASE64Decoder().decodeBuffer(auth.substring(5));
int off = 0, length, offset;
if (msg[8] == 1)
{
byte z = 0;
byte[] msg1 = {(byte)'N', (byte)'T', (byte)'L', (byte)'M',(byte)'S', (byte)'S', (byte)'P',
z,(byte)2, z, z, z, z, z, z, z,(byte)40, z, z, z,
(byte)1, (byte)130, z, z,z, (byte)2, (byte)2,
(byte)2, z, z, z, z, z, z, z, z, z, z, z, z};
response.setHeader("WWW-Authenticate", "NTLM " + new sun.misc.BASE64Encoder().encodeBuffer(msg1).trim());
response.sendError(response.SC_UNAUTHORIZED);
return "";
}
else if (msg[8] == 3)
{
off = 30;
length = msg[off+17]*256 + msg[off+16];
offset = msg[off+19]*256 + msg[off+18];
String remoteHost = new String(msg, offset, length);
length = msg[off+1]*256 + msg[off];
offset = msg[off+3]*256 + msg[off+2];
String domain = new String(msg, offset, length);
length = msg[off+9]*256 + msg[off+8];
offset = msg[off+11]*256 + msg[off+10];
user = new String(msg, offset, length);
}
}
}
catch(IOException e)
{
e.printStackTrace();
}
finally
{
return user;
}
}
}

The username session variable is being populated alright but possibly is interfering with struts' sessions when it calls a response.flushBuffer()?
Regards,
Barry
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Barry,
I have the same issue. Did you find out a solution for this?
Regards,
Thiagarajan
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic