Opps, forgot a parenthesis. It should be
if (MyString.equalsIngoreCase("clipArtManager")) {
Celeste
-----Original Message-----
From: Haseltine, Celeste [mailto:[EMAIL PROTECTED]]
Sent: Friday, July 12, 2002 1:52 PM
To: JRun-Talk
Subject: RE: Querystrings - Fustrated Newbie Question, Please Help
Boogie,
I suspected from your previous post that you were a VB/ASP programmer
without an OO background, or a background in C++. Lesson number one,
EVERYTHING in Java (but the primitive data types) are objects, including
Strings.
Forget a lot of what you know of VB/ASP. In the code below, you are trying
to compare two strings with the "==" operator. In VB, and I think ASP, the
"==" operator is overloaded behind the scenes allowing you to do a string
comparison. That functionality is not built into Java, though you could
write your own overloaded "==" operator to do string comparisons. Before
I answer your question, I suggest that if you have NOT downloaded the
documentation/help files for Java, do so and install them on your machine.
You will need them extensively!!! There is a windows version of the JavaDocs
that you can find if you do a google search (I can't remember the URL, but
I've installed it on all our Windows programmers machines). The version you
get packaged with your J2EE download from Sun is in HTML, and is hard to
navigate if you don't know what you are looking for.
If you go the JavaDocs, and search on the String object, you will find the
equivalent method of the string compare function. In this case, if you are
not concerned whether the string case matches or not, you would use <String
Object Name>.equalsIgnoreCase(second string to compare to String Object).
Since these are objects, you would do the following:
<%
String MyString = request.getParameter("loc");//declares string
object to hold returned param
if (MyString.equalsIngoreCase("clipArtManager") { // comparison
method of string object
Clip Art
} else {
do something else
}//end if
If you are NOT an object programmer, I also suggest that you get yourself a
very good basic Java book, and a basic JSP book. There is very little
similarity, in my opinion, between ASP 6.0 and true JSP/serlvet development.
And none whatsoever to VB.
Celeste
-----Original Message-----
From: Boogie Brown [mailto:[EMAIL PROTECTED]]
Sent: Friday, July 12, 2002 1:39 PM
To: JRun-Talk
Subject: Querystrings - Fustrated Newbie Question, Please Help
I am an ASP programmer moving to JSP. I am trying to run my first script and
capture a Querystring however it seem so dificult in JSP.
This is my code:
<%
} if (request.getParameter("loc") == "clipArtManager") {
%>
Clip Art
<%
} else {
%>
No Go
<%
}
%>
It is always returning No go. Why is this?
My other problem is that when I print out
request.getParameter("loc") I het 500 Null printed on the screen, with no
other data shown.
What is happening?
Please ANY help would be much appreciated.
MTB
______________________________________________________________________
Your ad could be here. Monies from ads go to support these lists and provide more
resources for the community. http://www.fusionauthority.com/ads.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists