Couple of things.
1) The code which you have sent us would throw a NullPointerException as the
string variable inputLine is null when you use it in the if statement.
2) Please do try to understand the difference between the == operator and
the equals(String s) method, it shall relieve you of a lot of problems later
on as well in your programming career :-).Just a friendly suggestion.
3) Another easier way could be to use the startsWith(String s) method of the
java.lang.String class.
Have a nice day.
With regards,
Sachin S. Khanna.
www.emailanorder.com
----- Original Message -----
From: Jean Chiang (���Q�g) <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, January 02, 2001 10:53 AM
Subject: The comparison between string and char.
> I am new to JSP. Who is going to help me? Thanks in advance.
> I read some input from a text file and the first parameter is an int and
> others are string. I have to do different action according to the first
> parameter.
> A part of my source code is listed as follows:
>
> In this case, when my first parameter is "1", it still shows "no". What's
> wrong? I suppose it cannot compare char and string. but how can I deal
with
> this stuff?
>
>
> <% BufferedReader in = new BufferedReader(
> new InputStreamReader(
> yc.getInputStream()));
>
> String inputLine;
>
> if ( inputLine.substring(0,1) == "1" ) {
> out.println("yes");
> }
> else {
> out.println("no");
> }
> %>
>
>
===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
> For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
> http://java.sun.com/products/jsp/faq.html
> http://www.esperanto.org.nz/jsp/jspfaq.html
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
>
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets