Peter--

You're beating your head against a *Java* problem, not a servlet one. In
particular, you're confusing the "==" operator's role.

Within Java, "==" compares two *references* to determine whether or not
they point to the same object. That is, given

String s = new String("This is a test");
String t = new String("This is a test");

s==t will always return false, even though the *contents* of these two
String objects are identical. What you want, instead, is

s.equals(t)

which will, given the above declarations, always return true.

I recognize you're comfortable with Perl, and that it must be frustrating
to beat your head against issues like this, but I strongly suggest you
pick up a good Java language book before you dive deeply into servlets.
Just as you can't write good Perl scripts without knowing the Perl
language, you can't write good servlets without knowing the Java language.

<SHAMELESS PLUG>
Alternatively, DevelopMentor (the folks I teach for) has a *very* good
Java course, "Essential Java". They have campuses in Boston, Portland and
Torrance (Southern California), as well as London, and hold
open-enrollment classes there about once a month or so. Might see about
getting the boss to cover one for you.
</SHAMELESS PLUG>

Ted Neward
http://www.javageeks.com/~tneward


On Mon, 24 Jan 2000, Peter Tierney wrote:

> Hello:
>
> This is the first time for me to post here and I hope my question isn't
> totally rudimentary.
>
> I am trying to convert a large program, which is currently in Perl, to
> one or a couple of Java servlets, but I can't seem to get past a simple
> step.  I can submit data to a servlet and do some basic tests if the
> fields sent are text or text area fields.  As soon as I try to test
> against a value sent via a radio, check box or menu element, I get
> strange results.  For example:
>
> res.setContentType("text/plain");
> PrintWriter out = res.getWriter();
> out.println(req.getParameter("radio1"));
> if (req.getParameter("radio1") == "y") {
>     out.println("Yes");
> }
> else {
>     out.println("No");
> }
>
> The output will look something like this:
> y
> No
>
> If the radio wasn't checked at all the first line of output will be
> null, but if I test against that I get a NullPointerException.  If I
> use:
> out.println(req.getParameterValues("radio1"));
> I get something like:
> [Ljava.lang.String;@7310a09a
>
> I don't need the memory address, I need the string in the memory
> address.
>
> This is something that should be simple and it's making me want to stay
> with Perl, if Servlet development is this peculiar.
>
> Thanks for ANY help given.
>
>
> --
> Peter Tierney
> [EMAIL PROTECTED]
> http://www.mckenzie-int.com
>
> The very wise person, when
> wishing to elevate people,
> Places their position below others.
>
> ___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to