| | |
javascript to jsp
Please support our JSP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved
![]() |
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.
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.
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
> 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.
> 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.
I don't accept change; I don't deserve to live.
I have finally resolved my problem using dojo, a javascript plateform used in Ajax development.
Dojo is really great and you can do whatever you want with it (almost) I'm passing in the javascript request the name of the function I want to call on the server side and on the servlet I'm doing a compareTo and I'm calling the required function.
After you just use a JSONObject to send data to the client and once you have your data on the client side you put it where you want in your html tags and that's all.
Thank you for all your answers
ciao
ovidiu
Dojo is really great and you can do whatever you want with it (almost) I'm passing in the javascript request the name of the function I want to call on the server side and on the servlet I'm doing a compareTo and I'm calling the required function.
After you just use a JSONObject to send data to the client and once you have your data on the client side you put it where you want in your html tags and that's all.
Thank you for all your answers
ciao
ovidiu
> 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
Glad you could figure it out. :-)
> 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. :-)
Last edited by ~s.o.s~; Jun 22nd, 2007 at 11:31 am.
I don't accept change; I don't deserve to live.
•
•
•
•
> 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 thegoGet()ordoPost()method of this servlet which then uses a bunch ofif..elsestatements 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. :-)
That's correct and it's exactly like this I have resolved the problem, it's a little bit long because I have a lot of if statements but it works so it's okay
ciao tutti
ovidiu
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.
Last edited by ~s.o.s~; Jun 22nd, 2007 at 12:09 pm.
I don't accept change; I don't deserve to live.
I know this kind of thing but it's a little bit ennoying to always pass the name of your functions to your servlet and not to be able to communicate directly with the class instances methods you want.
Also, I have found another way to do the same kind of thing, it's a tool called J2J(Javascript to jsp->http://www.servletsuite.com/servlets/j2j.htm) which does exactly what I want but I couldn't make it work.
Now it doesn't matter any more, all works perfectly with the usual method but it's a heavy way to make things work.
ciao
ovidiu
Also, I have found another way to do the same kind of thing, it's a tool called J2J(Javascript to jsp->http://www.servletsuite.com/servlets/j2j.htm) which does exactly what I want but I couldn't make it work.
Now it doesn't matter any more, all works perfectly with the usual method but it's a heavy way to make things work.
ciao
ovidiu
![]() |
Similar Threads
- Passing variable value from javascript to jsp page at run time (JSP)
- Autocomplete using javascript and jsp (JSP)
- javascript variable in jsp session (JSP)
- Passing paramter from javascript to jsp (JavaScript / DHTML / AJAX)
Other Threads in the JSP Forum
- Previous Thread: Help me about JSP problem...
- Next Thread: fetching data from the database
| Thread Tools | Search this Thread |
apache backbutton combobox connection database development directorystructure dynamicpagetitles eclipse frames glassfish imagetodatabse imageupload internet java javaee javascript jsf jsp jsppagetitles levels mvc2 mvcmodel2 network parameters passing ping printinserverinsteadofclient redirect request.getparameter response servlet servletdopost()readxml sessions software ssl state_saving_method stocks sun tomcat tutorial video web






