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

passing parameter from js to servlet

 
santu Naid
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to send few parameters from js to a servlet.
How can i do this?
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
Abhinav Srivastava
Ranch Hand
Posts: 354
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • 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
  • 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: 42967
73
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Ok thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic