We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now


validation for jsptextarea in bean class

Medium Priority
Last Modified: 2010-04-01
I want write code for validation on server side in java
In jsp i have textarea in that i want enter the comments

Validation is --When number of characters are less than or equals to 3000

I am working in atg application server and atg dynamoframework i developed jsp and bean for properties. in jsp i have button,when i click the button it check the validation and submit the button it show the error message or alert message

Watch Question

I'm not clear whether you want server side or client side validation.
I'm also not clear on whether number of characters greater than 3000 is a failure
or a success condition. I'll assume failure here.

Anyways, I'll give both of them.

<script type="text/javascript">
    function validateText()
        var text = document.MyForm.Text.value;
        if(text.length > 3000)
            alert('Text entered too long');


<form name="MyForm">
<textarea name="Text" rows="20" cols="60"></textarea>
<input type="button" value="Submit" onclick="javascript:validateText();">


Now, server side validation.

I don't know what you are using for Server Side coding. Servlets? Struts? what?
If it is servlets, you can do

String text = request.getParameter("Text");
if(text.length() > 3000)
    request.setAttribute("error", "Text too long");

// then forward to the same JSP you came from.

In your JSP, put something like this:

    if(request.getAttribute("error") != null)
<b><font color="red"><%=request.getAttribute("error")%></font></b>


Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.