validation for jsptextarea in bean class

Posted on 2006-03-26
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

Question by:srinivasraodumpala
1 Comment
LVL 10

Accepted Solution

radarsh earned 1000 total points
ID: 16297874
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>


Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Often times it's very very easy to extend a volume on a Linux instance in AWS, but impossible to shrink it. I wanted to contribute to the experts-exchange community a way of providing a procedure that works on an AWS instance. It can also be used on…
If anyone asked you to network diagram of the internet, it was drawn in the form of a fluffy cloud which further became known as cloud computing. Popularly cloud computing is defined as workloads that run over the internet in a commercial provider’s…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question