Ajax passing values to the server.

Posted on 2010-01-04
Last Modified: 2013-11-24
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);
Question by:gazdzid
    LVL 19

    Accepted 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.
    LVL 3

    Author Closing Comment


    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

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    Ajax and MVC 2 58
    copyEvens challenge 6 47
    count7 challenge 12 52
    HashMap Vs TreeMap 12 33
    Introduction HyperText Transfer Protocol ( or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
    Introduction Got endorsements from your clients?  Great!  There is almost nothing better than word-of-mouth advertising.  But how can you do that on the internet?  Sure you can make a page for endorsement quotations and list them all, but who is …
    The viewer will learn how to implement Singleton Design Pattern in Java.
    This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now