This week's book giveaway is in the Artificial Intelligence and Machine Learning forum.
We're giving away four copies of TensorFlow 2.0 in Action and have Thushan Ganegedara on-line!
See this thread for details.
Win a copy of TensorFlow 2.0 in Action this week in the Artificial Intelligence and Machine Learning forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

Assigning JSP variables to an IF statement

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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.
 
The human mind is a dangerous plaything. This tiny ad is pretty safe:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic