This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes JSP and the fly likes JSP variable typical problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "JSP variable typical problem" Watch "JSP variable typical problem" New topic
Author

JSP variable typical problem

Ramesh Sunkara
Ranch Hand

Joined: Mar 01, 2010
Posts: 78
Hi..

I have to get some values from a notepad file and show them in drop down list in my page.

First ,I retrieved the node values and stored them in an ArrayList .

I want to access these values in my JAVASCRIPT. I cant do that. Only the first value in the Arraylist is being populated many times.

I even declared "j' as static.

Please Help me!!!



David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

That's almost illegible.

In any case, you seem to have some confusion about how JSPs work: *all* of the Java scriptlets are executed *before* the HTML is returned to the client. *Then* the JavaScript is executed.

With that in mind, you should now understand why what you're doing will never work. There are several other major issues, but let's focus on understanding the basics first. For folks that found the original impossible to read, here it is formatted:The bottom line is that the file should be read in a servlet, the lines exposed in a scoped attribute, and rendered using JSP and JSTL. But before getting further help, let's make sure we're on the same page regarding the difference between Java and JavaScript and when they're executed.
Ramesh Sunkara
Ranch Hand

Joined: Mar 01, 2010
Posts: 78
Thanks DAVID

By surfing net i got the solution. It cleared my problem.

Is this the right of doing?




I pasted lines which i modified
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

I don't understand why you're using JavaScript at all.
 
wood burning stoves
 
subject: JSP variable typical problem