Meaningless Drivel is fun!
The moose likes Servlets and the fly likes JSP with a if-statment problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » Servlets
Bookmark "JSP with a if-statment problem" Watch "JSP with a if-statment problem" New topic

JSP with a if-statment problem

marko markovic

Joined: Mar 16, 2001
Posts: 28
here is my source code where i have problem:
<table width="100%" border=1 bgcolor="1188cc" bordercolor="#1177cc">
<% for (int i=0; i<Vector.size(); i++){
JspCriterium theJspCriterium = (JspCriterium)Vector.elementAt(i);
System.out.println(Vector.getName()+" "+theJspCriterium.getDescription()+" "+theJspCriterium.getComponentName());
if (theJspCriterium.isVisible()){
<td width="2%" bgcolor="1144cc" align="center">
<% if (theJspCriterium.isSelected()){ %>
<input type=checkbox NAME="ckbxs" VALUE="check" CHECKED>
<b><font name="Verdena" size="3" color="#FFFFFF">
<% }
else { %>
<input type=checkbox NAME="ckbxs" VALUE="check">
<b><font name="Verdena" size="3" color="#FFFFFF">
<% }%>
<% if(theJspCriterium.getComponentName()=="text "){
System.out.println("IF "+theJspCriterium.getName()+" "+theJspCriterium.getDescription()+"
"+theJspCriterium.getComponentName()); %>
<td width="20%" bgcolor="1144cc" align="right">
<b><font name="Verdena" size="3" color="#FFFFFF"> <%= theJspCriterium.getDescription()%>
<input width="78%" type=text value="<%= theJspCriterium.getValue()%>" name="texte"
size=55 maxlength=256 >
<% }%>
<% }
} %>

With these if(theJspCriterium.getComponentName()=="text ") i have a problem. the getComponentName()
is a method with a returned String value. I can write the value on the screen but i couldn't do the
I don't know why?
Could anyone help through, please?
Frank Carver

Joined: Jan 07, 1999
Posts: 6920
In Java to compare Strings you should always use the "equals" method. The "==" operator just compares the references.
Your if should read:

Read about me at ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
Have you checked out Aspose?
subject: JSP with a if-statment problem
It's not a secret anymore!