[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 329
  • Last Modified:

Ajax passing values to the server.

Quick and easy Ajax question:
Given:            A value is passed from js t to a servlet
Question:       does the value have to be used?

Found in one of my other posts Kuldeepchaturvedi: had a thought and thought to post it as a new question.  I agree that the passed value/parameter needs to be added to the select statement if it is tyo be considered but I disagree if all I want is to run a selectstatement.  Thank you in advance for your thoughts!!  Found below is the code in question the link canbe found above.

// in the query part you may have to add a where clause using the keys that you have recieved from client
resp = resp + "<Business>";
ResultSet rs=stmt.executeQuery(lsQuery);
1 Solution
Technically, you don't have to use the passed parameter if there is no need of it in your functionality.
I saw your code and I saw that you are passing a parameter to the server and hence I assumed that it must be needed on the server side. ( Otherwise there was no need to pass the parameter in the first place..).

I hope above explanation suffice to answer your question.

i.e. if the parameter is required to achieve a certain functionality ( filtering the list or something). Then you need to use it, from the techincal point of view there is not rule that mandates it.
gazdzidAuthor Commented:

I agree with your comment you can pass a value but do not have to use it.  Then your statement why would someone do that.

You and kadaba have been kind enough toassist me with my project currently I have a select statement without a where clause.  My idea is first get the select all to work then add the where clause.  Thank you for your explaination and participation.

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now