Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 639321
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:49:46+00:00 2026-05-13T20:49:46+00:00

I am new to JSP and generating a form with a text area. Is

  • 0

I am new to JSP and generating a form with a text area. Is there a library to convert the text from/to an HTML’s FORM TEXTAREA that will convert to/from entities for the URL to be properly formatted/parsed?

For example:

textarea (named ta):

simple test with ampersand & in textarea

url:

http://.../myapp.jsp?ta=simple+test+with+ampersand+%26+in+textarea
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T20:49:47+00:00Added an answer on May 13, 2026 at 8:49 pm

    If you are using scriptlets, you can use the URLEncoder.encode(String string, String encoding) to encode Strings in safely for use in URLs. It throws UnsupportedEncodingException, so make sure you catch that. Here’s an example JSP that encodes your string and displays it as the body of the document.

    <%@ page language="java"
      import="java.net.URLEncoder"
      contentType="text/html; charset=UTF-8"
      pageEncoding="UTF-8"%>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    
    <%
    
    String encoded = null;
    try {
        encoded = URLEncoder.encode("simple test with ampersand & in textarea", "UTF-8");
    } catch (Exception e) {
    
    }
    
    %>
    <html>
      <head>
        <title>MyTitle</title>
      </head>
      <body>
        <%=encoded%>
      </body>
    </html>
    

    It would be better practice to use JSTL, in this case specifically the <c:url> tag which will automatically encode its content. For example, to get the encoded String URL you mentioned in your question, you might do this:

    <c:url var="myEncodedURL" value="http://.../myapp.jsp">
      <c:param name="ta" value="simple test with ampersand & in textarea"/>
    </c:url>
    

    Which you could then access with the expression ${myEncodedURL}. If you’re not using JSTL at the moment then there’s a learning curve involved – you’ll need to set up the taglib, import it at then use it. You can see more on how to use this JSTL tag on developerworks.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to stackoverflow i have doubt regarding calling jsp from javascript file.
I'm trying to submit the page and forward to a new JSP. h:outputlink will
I am fairly new to JSP , i learned that to create a variable
Sorry if repost I’m new to JSP. I’m following a tutorial from a book,
Here's my issue: I have a html form that after a user fills in
I have done Java and JSP programming in the past, but I am new
The new extensions in .Net 3.5 allow functionality to be split out from interfaces.
In new C++ code, I tend to use the C++ iostream library instead of
I am new to JSPs and Servlets - I am wondering if there is
In a JSP page, I created a <h:form enctype=multipart/form-data> with some elements: <t:inputText> ,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.