This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes how to use javascript and scrptlet simultaneously Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "how to use javascript and scrptlet simultaneously" Watch "how to use javascript and scrptlet simultaneously" New topic
Author

how to use javascript and scrptlet simultaneously

abhijeet srivastava
Greenhorn

Joined: Aug 22, 2006
Posts: 26
Hi all!!



I have a jsp page on which there are two selection lists. One is for publisher names list and second is for journal names list corresponding to publisher selected in first selection list.



When publisher name is selected in first selection list then all journal names should be listed in second selection list. it requires fetching rows in database.





ie; action is onChange of first selection list ie; javascript and database is of scriptlet part.



how to do that??

I know that scriptlet can't be used in javascript. and it is possible by submitting this form. but i don't want to submit this form.



Please help me out.



Thanks
Sunil Vasudevan
Ranch Hand

Joined: Mar 05, 2007
Posts: 107
AJAX seems to be a good solution for your problem.

And you can use Scriptlets in JavaScript. I did not get it when you mentioned we cannot use JSP scriptlets with JavaScript.


Sunil.V<br />SCJP2, SCWCD1.4, SCBCD1.3
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by Sunil Vasudevan:
AJAX seems to be a good solution for your problem.

And you can use Scriptlets in JavaScript. I did not get it when you mentioned we cannot use JSP scriptlets with JavaScript.


You can mix scriptlets in with the code that writes the Javascript but the server side JSP will not be interpreted in the same time or place as the Javascript. Therefore, the scriptlet code can not be triggered by Javascript events happening on the client.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by abhijeet srivastava:
... how to do that?? ...


If the Javascript event needs to trigger a database read, you have two options:

1.) Send all possible combinations to the browser when the page is initially drawn. Unless the amount of data is small and not likely to grow, this might not be possible.

2.) Use AJAX to read from the server as needed without submitting the whole form.

In either case, the HTML/Javascript forum is probably a better place for this thread so I'm going to move it there for you.

-Ben
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to use javascript and scrptlet simultaneously
 
Similar Threads
Dynamic Changes in JSP - Urgent
Dynamic Jsp coding
Dependant drop down list boxes in JSP page
Populating second list based on selection of first list
how to get value selected in dropdown without using javascript and before form submission