Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to use javascript and scrptlet simultaneously

 
abhijeet srivastava
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic