File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can't get parameter from request

 
Dave Wingate
Ranch Hand
Posts: 262
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
anupa oru
Ranch Hand
Posts: 118
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64185
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Dave Wingate
Ranch Hand
Posts: 262
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64185
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic