This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Svelte and Sapper in Action and have Mark Volkmann on-line!
See this thread for details.
Win a copy of Svelte and Sapper in Action this week in the JavaScript 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
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Doubt in JSP Code

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The code is like this
if(patharr[2]=='Sample´┐Ż)

I wanna remove that word sample and get the value from javacode, it is available in projname.It will fetch the value Sample. Now how do I display it with sigle quotes 'Sample'


Is this correct

if(patharr[2]=='<%=projname%>')


Thanks in advance
Nithya
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It looks like it might work. Still, you are in the best position to find out.
 
Nithya Venkatraman
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks
 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if u r using jsp variable values in
''javascript functions '' it works fine ....

i did not understand how will this help u in java programme....
 
Nithya Venkatraman
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

Im sorry for not mentioning. Its a jsp page. Where I have written java code in <% %> and projname gets its value there. So how do I get the value being used in the page.
 
satish sathineni
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Till now i did not understand what u want...

what i understood from u r question is u want know how a java variable used in jsp page...

This could be done primarily making available that java variable or value through the
implicit objects ie., Request or Session

by adding the variable to the Request object and can retrieve the value from the request object and use it in the jsp variable....

Satish....
 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi where are u storing the variable ???
 
Nithya Venkatraman
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is my doubt:

I have a jsp page with the foll code and I wanna access patharr inside the <% %> of the same jsp.



var patharr=new Array();

patharr=Entirepath.split('.');



if(patharr[2]=='General')

document.fetchdocsform.selproj.value="0";

else

<%

Wanna access patharr[1] here. It will be used as arg for a method in some java program.

%>


Please help
 
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All that you write in your JavaScript code gets executed on the client side...that is after it reaches the client browser from the server . Whatever you include within the <% ..... %> tags gets executed on the server. This is the first process. So, by the time the client-side JavaScript gets a chance to execute, all the code within the <% ..... %> tags would have already got executed on the server side.

What does a JSP finally end up as? The JSP gets translated into a servlet and then a class file and this class file is executed by the server.

Now think...will you be able to pass that JavaScript variable as a parameter to any method?!
 
Nithya Venkatraman
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ya I understood it now...
Thanks a lot!
Will do it in a different way now.
 
Won't you please? Please won't you be my neighbor? - Fred Rogers. Tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic