• 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

Can't get parameter from request

 
Ranch Hand
Posts: 262
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Friends help you move. Good friends help you move bodies. This tiny ad will help:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic