validation for jsptextarea in bean class

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

    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

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Suggested Solutions

    Synchronize a new Active Directory domain with an existing Office 365 tenant
    Many companies are looking to get out of the datacenter business and to services like Microsoft Azure to provide Infrastructure as a Service (IaaS) solutions for legacy client server workloads, rather than continuing to make capital investments in h…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    754 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

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now