aspose file tools*
The moose likes JSP and the fly likes Can't get parameter from request Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Can Watch "Can New topic
Author

Can't get parameter from request

Dave Wingate
Ranch Hand

Joined: Mar 26, 2002
Posts: 262
I'm new to JSPs and just wanted to write a simple login type page. I can't even get the submitted parameters from the request.

Here's what I'm trying:




Everytime I submit, the page loads with null for the user name parameter. I'd really appreciate any insight you could offer.


Fun programming etcetera!
anupa oru
Ranch Hand

Joined: Jan 15, 2005
Posts: 118
Hi,

I believe you have to use name attribute in place of id attribute for <input> element as
<input type="text" name="userName">

I hope this will solve your problem.
Thanks
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61233
    
  66

You are not doing anything to set the value of your input elements. If you want to preload an element with a value it needs a value attribute.

In your example, something like:



Disclaimer: not that I would do things this way. I would never submit to a JSP -- always to a servlet, and I would favor the JSTL over scriptlet expressions. But that's another show...
[ May 11, 2005: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Dave Wingate
Ranch Hand

Joined: Mar 26, 2002
Posts: 262
Disclaimer: not that I would do things this way. I would never submit to a JSP -- always to a servlet


Could you help a newbie out and let me know why it is a bad idea to submit to a JSP?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61233
    
  66

In (at least what I would consider) a properly achitected web application, JSPs serve as presentation mechansims only. They perform no processing of their own except what is necessary for "display support". Such a pattern is frequently refered to as "Model 2" or "MVC" or even "n-tiered". There has been much written on these subjects.

Inherently, when submitting a form, processing of the form data occurs. Such processing is inappropriate for a JSP in a web app following this pattern.

In fact, especially if you are using a JSP 2.0 container, it's better to write what have become termed "scriptless" JSP pages. That is: pages that contain no java. No scriptlets, no declarations, no scriptlet expressions. Rather, these pages rely upon the EL (Expression Language), JSTL (JSP Standard Tag Library), JSP actions, and custom actions (formerly known as "custom tags") to perform their jobs.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Can't get parameter from request