This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Servlets and the fly likes Doubt in JSP Code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Doubt in JSP Code" Watch "Doubt in JSP Code" New topic
Author

Doubt in JSP Code

Nithya Venkatraman
Ranch Hand

Joined: Apr 11, 2004
Posts: 39
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


Nithya<br />SCJP(1.2), SCWCD(1.4)
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

It looks like it might work. Still, you are in the best position to find out.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Nithya Venkatraman
Ranch Hand

Joined: Apr 11, 2004
Posts: 39
thanks
satish sathineni
Ranch Hand

Joined: May 03, 2004
Posts: 46
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

Joined: Apr 11, 2004
Posts: 39
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

Joined: May 03, 2004
Posts: 46
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

Joined: Jul 14, 2004
Posts: 39
hi where are u storing the variable ???


Software Engineer (SCJP)<br />USTechnology, CA
Nithya Venkatraman
Ranch Hand

Joined: Apr 11, 2004
Posts: 39
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

Joined: Jul 04, 2004
Posts: 195
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?!


Vijayendra <br /> <br />"The harder you train in peace, the lesser you bleed in war"
Nithya Venkatraman
Ranch Hand

Joined: Apr 11, 2004
Posts: 39
Ya I understood it now...
Thanks a lot!
Will do it in a different way now.
 
Consider Paul's rocket mass heater.
 
subject: Doubt in JSP Code