File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes HTML, CSS and JavaScript and the fly likes Servlet Called From Javascript Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Servlet Called From Javascript" Watch "Servlet Called From Javascript" New topic

Servlet Called From Javascript

carina caoor
Ranch Hand

Joined: Jun 23, 2007
Posts: 300

Hi im my application i am calling a servlet from javascript with parameter as comma separated string values but as the comma separated string becomes long its not correctly getting passes as parameter to the servlet.
i have got 200 string made as a one comma separated string value now when i pass this as parameter to servlet n call it the servlet is not getting invoked ,url is not properly created.

when i put the url in the addressbar with the long csvstring... it pastes part of csvstring in address bar and rest of the string is not getting pasted and i could not add a charactar to the url further .. this is the limitation with the get request might be ...
can somebody suggest me any solution for this
Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

this is the limitation with the get request might be

Most probably. In which case you will need to use a POST request instead of GET.

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
carina caoor
Ranch Hand

Joined: Jun 23, 2007
Posts: 300

from a javascript how do i pass parameters in post to a servlet ...
any example please, because javascript here i spreparing the csv string and i need to pass it to the servlet as parameter.
carina caoor
Ranch Hand

Joined: Jun 23, 2007
Posts: 300

any example where servlet is invoked by passing some long charactars as parameters from javascript ... or calling a servlet and passing parameters in post message body could help me out in solving the problem. can anyone give me this example please
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 60799

In order to generate a POST you need a form with a method of "post". Set the URL to the servelt as the action of the form tag.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
carina caoor
Ranch Hand

Joined: Jun 23, 2007
Posts: 300

My form action is post method , here i am calling a servlet from javascript and passing a long csv string that is obtained after the user inputs data, i am not passing here the data what user enters, Actually user here in my screen uploads an excel file , i am reading a particular column from the excel file and populating the column values on the screen in a grid, now from the grid i read columns selected by user and make a csv string of the selected values and pass it to servlet along with the URL as get request pass parameters , but as the csv string created contain some 1000 strings separated by comma the url is not properly created and servlet is not getting invoked, if the csv string contains some 100 strings the url is properly getting created and servlet is being invoked , but my requirement is a long csv string to be passed to servlet as parameter ....
can you suggest me some solution please
I agree. Here's the link:
subject: Servlet Called From Javascript
Similar Threads
Pass Javscript array from jsp to servlet
Problem with between expresion (EJB QL)
How to pass a collection to 'IN' parameter in native query
Open New Window