• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

calling a scriptlet on submit

 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 382
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
I am going down to the lab. Do NOT let anyone in. Not even this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic