Re: sending email from localhost with JavaMail -- WEIRD prob
w/servlet...
maya wrote:
well, here's a WEIRD problem I'm having with the servlet:
<input type="text" id="name" />
^^
sName = request.getParameter("name");
this does not work!!! param does not get passsed..
That's because you asked for a parameter named "name" and there isn't
one - nothing weird about it (no matter how many exclamation points
you use). The 'name' attribute of the <input> tag is what identifies
parameters, not the 'id' attribute.
it only gets passed if in form I do:
<input type="text" name="name" />
^^^^
this is totally bizarre, I did NOT have this problem in the JSP.. the
It's neither bizarre nor a problem - the parameters you get from
'request.getParameter()' by definition are those that have names given
by the attribute 'name', not by the attribute 'id'.
reason I need to do "id" and not "name" in the form is that all my stuff
has to validate as XHTML, and HTML code doesn't validate as XHTML if you
use "name" to identify elements (go figure.. who makes these stupid
decisions?? what's wrong with using "name" to identify an element?? esp
if using "id" doesn't work in some situations??)
You still have to use 'name' to identify parameters. Identification
of elements and identification of parameters are different things.
The 'id' attribute identifies elements for XML; it has nothing to do
with passing parameters. For that you need the 'name' attribute.
this doesn't make any sense at all.. WHY am I having this problem with
the servlet but not with the JSP????
One question mark suffices to indicate an interrogative.
I don't know why the JSP works differently, but if you don't have a
'name' attribute on your parameters, you're doing it wrong for
servlets even if they do have JSP for source.
'getParameter()' works only with parameters that were given a name
with the 'name' attribute. If you look at
<http://w3schools.com/tags/att_input_name.asp>
it documents that the 'name' attribute "is used to identify form data
after it has been submitted to the server" and that "[o]nly form
elements with a name attribute will have their values passed when
submitting a form".
That has not changed between pre-X HTML and XHTML.
--
Lew