Solved

if else and syntax problem

Posted on 2002-07-18
14
183 Views
Last Modified: 2010-03-31
The following was working then I had to add another condition and now it is not working if I add what is blocked out

- what i wanted to add was
refURL.endsWith("esccServlet") ||  (refURI.beginsWith("pbc2"))

from
refURL.endsWith("esccServlet") )
What is not right??

<%
boolean  display = false ;
String refURL = request.getHeader("referer");
//String refURI = request.getRequestURI("uri");
if ( (new Integer(passedCalculatedElecSerDay)).intValue()>0 )
{
display = true;
}
if ( (new Integer(passedCalculatedElecSerYear)).intValue()>0 )
{
display = true;
}
if  ( display == true && refURL != null && 
 //refURL.endsWith("esccServlet") ||  (refURI.beginsWith("pbc2"))
  //(refURI.beginsWith("pbc2"))
    refURL.endsWith("esccServlet"))
  //(refURI.endsWith("pbc2"))
{
%>    
0
Comment
Question by:schroom
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 4
  • 3
14 Comments
 
LVL 9

Expert Comment

by:Ovi
ID: 7162031
if  ( display == true && refURL != null &&  (refURL.endsWith("esccServlet") ||  (refURI.beginsWith("pbc2")))
0
 
LVL 35

Expert Comment

by:girionis
ID: 7162035
 You have statements without a OR and/or AND checking. You cannot do it. And you have more parenthesis than actual needed. (refURI.beginsWith("pbc2")) can be written as refURI.beginsWith("pbc2").

  I am not sure what exactly you are tryign to look for but the above coudl be written as:

if  (  (display == true && refURL != null &&
      refURL.endsWith("esccServlet")) ||  
     (refURI.beginsWith("pbc2") && 
     refURI.beginsWith("pbc2") && 
     refURL.endsWith("esccServlet") && 
     refURI.endsWith("pbc2"))
     )

  Change the OR/AND checking and parenthesis accordingly to obtain whatever result.

  Hope it helps.
0
 

Author Comment

by:schroom
ID: 7162040
this is the error I get with the below:
expected. if ( display == true && refURL != null && (refURL.endsWith("esccServlet") || (refURI.startsWith("pbc2"))) ^ /u/ws03/as01/jit/default_host/pbcdev/_10calculator_2D_e_jsp_0.java:649: 'else' without 'if'. } else { ^ 2 errors

<%
boolean  display = false ;
String refURL = request.getHeader("referer");
String refURI = request.getRequestURI();
if ( (new Integer(passedCalculatedElecSerDay)).intValue()>0 )
{
display = true;
}
if ( (new Integer(passedCalculatedElecSerYear)).intValue()>0 )
{
display = true;
}

  if  ( display == true && refURL != null &&  (refURL.endsWith("esccServlet") ||  (refURI.startsWith("pbc2")))
{
%>    
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 35

Expert Comment

by:girionis
ID: 7162090
 Make sure you have a matching closing bracket somewhere.

  And put everythign inside parenthesis, just in case:

 if  ( (display == true) && (refURL != null) &&  (refURL.endsWith("esccServlet") ||  (refURI.startsWith("pbc2")))
0
 
LVL 35

Accepted Solution

by:
girionis earned 100 total points
ID: 7162100
After more careful consideration this:

 if  ( display == true && refURL != null &&  (refURL.endsWith("esccServlet") ||  (refURI.startsWith("pbc2")))


  should be:

  if  ( display == true && refURL != null &&  (refURL.endsWith("esccServlet") ||  refURI.startsWith("pbc2")))

  Hope it helps.
0
 

Author Comment

by:schroom
ID: 7162112
Getting closer this is my errro now.
??
ANy more suggestions thanks for your help

Unable to compile class for JSP "/15calculator-e.jsp" /u/ws03/as01/jit/default_host/pbcdev/_15calculator_2D_e_jsp_0.java:630: Undefined variable or class name: refURI if ( display == true && refURL != null && (refURL.endsWith("esccServlet") || refURI.startsWith("pbc2"))) ^ Note: /u/ws03/as01/jit/default_host/pbcdev/_15calculator_2D_e_jsp_0.java uses or overrides a deprecated API. Recompile with "-deprecation" for details. 1 error, 1 warning
0
 

Author Comment

by:schroom
ID: 7162121
Getting closer this is my errro now.
??
ANy more suggestions thanks for your help

Unable to compile class for JSP "/15calculator-e.jsp" /u/ws03/as01/jit/default_host/pbcdev/_15calculator_2D_e_jsp_0.java:630: Undefined variable or class name: refURI if ( display == true && refURL != null && (refURL.endsWith("esccServlet") || refURI.startsWith("pbc2"))) ^ Note: /u/ws03/as01/jit/default_host/pbcdev/_15calculator_2D_e_jsp_0.java uses or overrides a deprecated API. Recompile with "-deprecation" for details. 1 error, 1 warning
0
 

Author Comment

by:schroom
ID: 7162128
it is good now thanks
I had to put back in
String refURI = request.getRequestURI();

<%
boolean  display = false ;
String refURL = request.getHeader("referer");
String refURI = request.getRequestURI();
if ( (new Integer(passedCalculatedElecSerDay)).intValue()>0 )
{
display = true;
}
if ( (new Integer(passedCalculatedElecSerYear)).intValue()>0 )
{
display = true;
}
if  ( display == true && refURL != null &&  (refURL.endsWith("esccServlet") ||  refURI.startsWith("pbc2")))
{
%>    
0
 
LVL 35

Expert Comment

by:girionis
ID: 7162147
 Thank you schroom I am glad I helped as well but I think Ovi is worth the points since he was the one who suggested the solution. ]:-)
0
 
LVL 9

Expert Comment

by:Ovi
ID: 7162300
if  ( display == true && refURL != null &&  (refURL.endsWith("esccServlet") ||  (refURI.beginsWith("pbc2")))
0
 

Author Comment

by:schroom
ID: 7162312
Sorry Ovi, there seemed to be a lag or something in the posts
0
 

Author Comment

by:schroom
ID: 7162313
Sorry Ovi, there seemed to be a lag or something in the posts
0
 

Author Comment

by:schroom
ID: 7162338
Sorry Ovi, there seemed to be a lag or something in the posts
0
 
LVL 9

Expert Comment

by:Ovi
ID: 7162465
I don't uderstand what you meen. My comment was the first posted to your question ... But any way, is not a problem that you have graded the points to someone else. Glad to see you happy with your problem resolved ... -:)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question