Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt in JSP Code

 
Nithya Venkatraman
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
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate 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
 
satish sathineni
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....
 
unni krishna
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
 
Vijayendra V Rao
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.
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic