yes. I have tons of ideas.
And no, what you're thinking of doing isn't going to work (at least not in the way you probably think to do it).
jwenting
duckman
8,392 posts since Nov 2004
Reputation Points: 1,662
Solved Threads: 337
like I said, you don't realise what you're dealing with here.
What you're effectively saying is that you want to call private method on a class without having access to an instance of that class.
Even if you had an instance you'd be hard pressed to call that method (there are ways, but they're only for experts).
Think of trying to use the car stereo in the car of someone in another country to listen, from your own bedroom, to a CD that's sitting on your neighbour's kitchen table who's on vacation and you don't have the key to his door.
And oh, that car stereo doesn't have a CD player and the car is turned off so the stereo has no power.
jwenting
duckman
8,392 posts since Nov 2004
Reputation Points: 1,662
Solved Threads: 337
> I would like to call a function situated on a server side servlet or in
> a jsp file with a javascript function (client side) and to show the
> results returned by the servlet's function.
Any reason for this weird requirement. There is as such no problem which requires you to do such a thing. Use normal AJAX calls and you would be a happy man.
~s.o.s~
Failure as a human
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 734
> I want to call on the server side and on the servlet I'm doing a compareTo and I'm calling the
> required function.
Let me guess, you pass a string which would probably be the name or the code of the function which you want to call in the servlet. This string is received by the goGet() or doPost() method of this servlet which then uses a bunch of if..else statements to decide what is the code passed from the client side and then decides which function has to be executed. Isn't it?
Glad you could figure it out. :-)
~s.o.s~
Failure as a human
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 734
It seems like you failed to frame your question properly in your first post, since what I mentioned is exactly how things are normally done using servlets. As you can see, you are not _directly_ invoking the private function of the Java class but requesting the servlet to execute the method which you want. There is a big difference you know.
~s.o.s~
Failure as a human
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 734
Maybe you need to see this .
~s.o.s~
Failure as a human
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 734
idiotic and highly dangerous to have anything in place that can bypass the normal request/response system and call any method it wants directly.
Security leaks guaranteed, such a thing is a major billboard with all flashing light for crackers, giving them complete root access to your machine at their leasure.
jwenting
duckman
8,392 posts since Nov 2004
Reputation Points: 1,662
Solved Threads: 337