• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Assigning JSP variables to an IF statement

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello everyone,
I am pretty new to JSP and Javascript, and I am trying to modify a delivered JSP page.
Is there anyway to get this to work:
<input type="hidden" name="field1" value='<extn_doc_print:getElement bob="loginUser" name="userLogin"/>'>
<input type="hidden" name="field2" value='<extn_doc_print:getElement bob="docCreator" name="userLogin"/>'>
<input type="hidden" name="field3" value='<extn_doc_print:getElement bob="docCreator" name="userLogin"/>'>

<script language="javascript">
alert(displayappl());
</script>
<%

if (('<extn_doc_print:getElement bob="loginUser" name="userLogin"/>' )== '<extn_doc_print:getElement bob="docCreator" name="userLogin"/>') { %>

<jsp:include page="/docApprove.jsp" flush="true"/>
<% } %>

Any help will be appreciated.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is this the code you are trying to use exactly?
what is displayappl()
What is that if statement doing?
Eric
 
Eric Sweeney
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Eric,
The Javascript variable is only a test I added for a javascript function I created, Not part of this problem. The code is only a snippet of the total JSP page.
I want the IF statement to compare the <field1> name value on the '<input type' statement to <field2> name value of the '<input type' statement, and if they are equal, do the <jsp:include page="/docApprove.jsp" flush="true"/> statement.
Can I do that?
Thanks
posted December 16, 2003 10:09 AM
--------------------------------------------------------------------------------
Hello everyone,
I am pretty new to JSP and Javascript, and I am trying to modify a delivered JSP page.
Is there anyway to get this to work:
<input type="hidden" name="field1" value='<extn_doc_print:getElement bob="loginUser" name="userLogin"/>'>
<input type="hidden" name="field2" value='<extn_doc_print:getElement bob="docCreator" name="userLogin"/>'>
<input type="hidden" name="field3" value='<extn_doc_print:getElement bob="docCreator" name="userLogin"/>'>

<script language="javascript">
alert(displayappl());
</script>
<%

if (('<extn_doc_print:getElement bob="loginUser" name="userLogin"/>' )== '<extn_doc_print:getElement bob="docCreator" name="userLogin"/>') { %>
<jsp:include page="/docApprove.jsp" flush="true"/>
<% } %>
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are going to have to do it all on the jsp side since jsp and javascript can not act together.
JavaScript on interacts with the client side after the whole page loads.
Eric
 
Eric Sweeney
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the response Eric,
So there is no way to bind:
"<input type="hidden" name="field1" value='<extn_doc_print:getElement bob="loginUser" name="userLogin"/>'>"
to a variable to use in an JSP 'IF' statement, even if both are in JSP and not in Javascript?
Thanks
 
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Eric,
You have your answer in one of your posts. The following code is quite close:

The only problem I see is that you are trying to compare some strings and not objects. In that case you want to use the String equals function.
Regards,
Manfred.
reply
    Bookmark Topic Watch Topic
  • New Topic