• 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

passing parameter from js to servlet

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to send few parameters from js to a servlet.
How can i do this?
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

There are various ways this might be done, depending on whether the current page should be replaced by a different one,a nd whether the parameters are part of a link clicked by the user or part of an HTML form. Can you tell us a bit more about the circumstances?
 
santu Naid
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually its an jsp page,
In this page there are many hidden fields with ids, which are made visible by calling js functions, which are called on onclick.
My job is to make an array in which i have save the ids of these hidden fields and save in a session object,
so that when i come back to this page again, the hidden fields are in visible state.

So i want to send this array to the servlet
 
Ranch Hand
Posts: 354
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One way could be this -
You can set the values in hidden "input" fields which are in the same html form that is submitted. You can retrieve these values on the server using
request.getParameter("fieldName"); or request.getParameterValues("fieldName") and send them back to the page.
 
santu Naid
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks,
Actually i knew this method
but wanted an another way,
Any way thanks,
i just want to ask is there any way by which i can directly access a js variable in a servlet?
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

is there any way by which i can directly access a js variable in a servlet?


Since JavaScript runs on the client, while servlets run on the server, you can't.
 
santu Naid
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok thanks
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic