File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

why doesn't request.getParameter( "j_username" ) work?

 
Sheldon Plankton
Ranch Hand
Posts: 33
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Friends,
I am trying to based my content on the user that has logged in.
I am basically using the logon.jsp from the J2EE 1.4 tutorial ...

... and I want to use the value of j_username in this jsp ...

... and here is the HTMl that gets generated ...

I tink that I am not getting anything from the request.getParameter( "j_username" ); call.
What am I doing wrong?
 
Sadanand Murthy
Ranch Hand
Posts: 382
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where is the action j_security_check implemented? Is the form submitting to a servlet? How is the 2nd jsp getting displayed? Is the request getting dispatched to the 2nd jsp?
Request object is specific to a request. What is likely happening is that the form is getting submitted & its request is being processed (perhaps in a servlet) & the servlet is displaying the next jsp. The 2nd jsp will not have access to the request object of the 1st jsp unless you forward the request & response objects via the RequestDispatcher.
If you are using a servlet you can do the following:
getServletContext().getRequestDispatcher(urlForJSP).forward(request, response)
 
Sheldon Plankton
Ranch Hand
Posts: 33
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where is the action j_security_check implemented? Is the form submitting to a servlet? How is the 2nd jsp getting displayed? Is the request getting dispatched to the 2nd jsp?
I don't know ... I am using Tomcat and the J2EE1.4 Application Server I used the "deploytool" to make a WAR file. I tried to ape the example "FormBasedAuthenication" from the J2EE 1.4 Tutorial to create my own formbased logon screen. The example in the Sun tutorial displays the logged on user's username like so ...

Does this mean my jsp should look like this?

Thanks for the reply!
[ February 18, 2004: Message edited by: Sheldon Plankton ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64205
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The getParameter family of methods do not work with multi-part form data.
 
Sheldon Plankton
Ranch Hand
Posts: 33
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bear,
Thanks for the reply. Are you saying that I need to change ...

... to ...

...? If make this change will I still be able to upload files?
Thanks!
[ February 18, 2004: Message edited by: Sheldon Plankton ]
[ February 18, 2004: Message edited by: Sheldon Plankton ]
[ February 18, 2004: Message edited by: Sheldon Plankton ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64205
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If make this change will I still be able to upload files?

No. Basically, uploading files and using getParameter are incompatible. To upload a file you need to use a multi-part form, which precludes the use of getParameter. You need to parse the input yourself or use a third party package (like com.oreilly.servlet) that does it for you.
 
Sheldon Plankton
Ranch Hand
Posts: 33
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah man!
have you ever used Jakarta's FileUpLoad? I guess that's what I'll try next.
Thanks for the info. You jut saved me a lot of wasted time and fustration.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64205
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The 'cos' package is the only one I've personally used. This topic has come up before, so I'd suggest searching this (and the Servlets) forum for more info.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic