Dear friends,
I want to know if we can pass a text area value of great length from jsp to servlet as a url parameter. I have tried it but it sends a null value to the servlet.
Please help me. It's urgent.
Thanks and regards.
Sriprasad Kannan.
Dear friends,
I want to know if we can pass a text area value of great length from jsp to servlet as a url parameter. I have tried it but it sends a null value to the servlet.
Please help me. It's urgent.
Thanks and regards.
Sriprasad Kannan.
Short answer: avoid putting very large textarea content into a URL. Use HTTP POST (a form with method="post") so the browser/servers don't truncate or log the data and you avoid hitting practical URL-length limits. pointed out the browser/URL-length issue — that can matter, but the more common causes of a null value are form/parameter mistakes or encoding problems.
Common checks and a minimal pattern to follow:
name attribute and the form method matches how you read it in the servlet (doPost vs doGet).request.getQueryString() / parameter names in the servlet if you see null.Example JSP form and servlet sketch:
<form method="post" action="SubmitServlet" accept-charset="UTF-8">
<textarea name="content"></textarea>
<button type="submit">Send</button>
</form> protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
req.setCharacterEncoding("UTF-8"); // must come before getParameter for POST
String content = req.getParameter("content");
// process content
} If you must use a GET (not recommended for large/sensitive text), URL-encode the value from JavaScript with encodeURIComponent(...) before appending it to the query string. Better alternatives are: POST; store the large text on the server (DB/session/temp file) and pass back a short ID in the URL; or upload via multipart if files are involved.
Quick troubleshooting checklist (useful given fixed a typo): confirm name spelling, check the form method, verify you call setCharacterEncoding() before getParameter() for POST, look for JavaScript that alters the value, and inspect server/container limits (web server and servlet container can impose request-body or header/URL size limits). Security note: never put sensitive text in a URL — it ends up in logs and browser history.
Jump to Post— hericles 289What browser are you using? They have differing specs on how long a URL they can process. I maybe out of date but I believe IE can only take 2048 (or there abouts). Other browsers maybe able to handle longer lengths and the http spec doesn't mention a maximum length.
…
What browser are you using? They have differing specs on how long a URL they can process. I maybe out of date but I believe IE can only take 2048 (or there abouts). Other browsers maybe able to handle longer lengths and the http spec doesn't mention a maximum length.
Also, there simply be an error in your code that is causing the null. Have you removed that as a possiblity?
I'm using Google Chrome but the issue has been resolved now. It seems that I missed out on asingle character which caused the error. Now, it's working properly.
Anyways, Thanks for your reply and help.
Sriprasad Kannan.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.