Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

calling a scriptlet on submit

 
dhriti joshi
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
i want that when i submit the form a part of scriptlet on same jsp should run,
how do i do it.
please help.
thanks.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65223
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't.
JSP runs on the server to format the HTML page to send to the browser. Once on the browser, you can manipulate the page using Javascript. The JSP's work is long done and the only way you can get back to the server is to submit a new request.
 
Sadanand Murthy
Ranch Hand
Posts: 382
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why do you want to do that Dhriti? What do you want to accomplish by doing that? Can you post this information? That will enable us to give you a better approach on how to do it. It is generally considered not a good practice to embed java scriptlets in JSPs. There are always exceptions to rules; however if you can get away from embedding scriptles in JSPs you should.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65223
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's really not an issue of whether there are scriplets in the JSP page or not. The point is, any scriplets are run on the server long before the page is sent to the browser, and there is no way to "trigger" one of the scriplets on a client-side event like onsubmit.
 
Anil Kumar
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can submit to the same jsp with a value assigned to a hidden form field. Depending upon the value of this hidden field you can get the neccesary scriptlet to be executed on the server. I prefer this way when the same gui is to be maintained through a sequence of dynamic selections like country>state etc.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic