Forums Register Login

Calling Servlet with Javascript ?

+Pie Number of slices to send: Send
hi friends
I would want to know if call servlet from javascript is good practice or no?
I always call servlet from other servlet (mvc) but now in my job i must modify an application , tshi application call servlet from javascript!
that not look good!
Can someone give me an opinion?

Thanks
2
+Pie Number of slices to send: Send
There are many fine applications that use Ajax/Javascript to make calls to a Servlet. What in particular do find unappealing in the way your application is doing it? Can you post an example?
+Pie Number of slices to send: Send
 

Junilu Lacar wrote:There are many fine applications that use Ajax/Javascript to make calls to a Servlet. What in particular do find unappealing in the way your application is doing it? Can you post an example?



I just was curious. I guess is not good practice for security. Or i am wrong?
Here a line example:

where 'ProgramLauncher4' is a servlet.

Thanks for the reply.
+Pie Number of slices to send: Send
 

jhon masco wrote:I just was curious. I guess is not good practice for security. Or i am wrong?



I don't know. What do you consider insecure about that code?

(There's plenty of places in web applications where you can do insecure things; I'm just asking which of the long list of insecure things applies in this case.)
1
+Pie Number of slices to send: Send
Actually, you cannot call a servlet from another servlet. You can only forward, unless you just break into the servlet's processing methods by main brute force.

You definitely don't "call" a servlet from JavaScript. Since JavaScript runs on the client and the servlet runs on the server, the client can only make an HTTP(S) request that invokes a servlet's processing method.

The biggest security risks in a J2EE application don't come so much from whether requests were made directly from a browser or via AJAX, but from whether or not the webapp was designed secure to begin with. Which is the main reason I make so much noise about not writing your own security system if the J2EE-standard one can be used instead.
+Pie Number of slices to send: Send
Thanks for all the replies.
Then i would conclude that is not bad use javascript or ajax for call servlet (redirect).
Yes Tim, you are right when you say than the most important is the web application design.
Particularly i dont like when i can see the code of any file (.js.jsp.php, etc) from of my web browser.!
That is this case. I can access to the javascript files from the browser. That is a design problem definitively.!

Thanks again.
+Pie Number of slices to send: Send
 

jhon masco wrote:I can access to the javascript files from the browser. That is a design problem definitively.!


Again you are making assertions without any basis whatsoever in fact. Why is this a "design problem"?
+Pie Number of slices to send: Send
 

I would want to know if call servlet from javascript is good practice or no?



Yes it is a good practice because by using javascript you can enrich the user experience... rather than using flash content(which can be annoying at times)...
Moreover you cannot call a servlet without using some kind of inter-laying code, example : javascript or ajax ....
+Pie Number of slices to send: Send
 

Shivom Shukla wrote:
Moreover you cannot call a servlet without using some kind of inter-laying code, example : javascript or ajax ....


That is not correct. A servlet can be the target of a form or a link.
+Pie Number of slices to send: Send
Jhon,

I dont know why you are feeling this is not good pratice, but for your information, GMAIL is popular because most of the functionalities are implemented by using AJAX(calling servlet using java script).

Thanks & Regards

Pandian R
+Pie Number of slices to send: Send
Sorry fro delay.
Thanks all for the answers. You win!!!
From now I will try to use other ways(javascript, ajax, etc) to call servlets.

Thank you.
Surfs up space ponies, I'm making gravy without this lumpy, tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 2753 times.
Similar Threads
calling a servlet from a javascript
Calling Servlet with contenttype = application/force-download from javascript
JOptionPane No X11 DISPLAY error
calling a servlet from javascript function??
request attributes in new request from javascript?
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 14:33:08.