Validation in JSP

Hi,
I am stuck with validation on same jsp page:
Here is the detail:
I have a couple of input fields in form, and if users enter wrong name and id
the validation error will be shown on the same jsp page.
I know there is no problem if using struts validation function.
But for my case, is just simple jsp without other component replying on.
How to achieve this?
Actually the original validation logic is done by jave script
which collected all error message into formated variable,
The popup window for error message display will be shown once users click submit button
Any help?

use another jsp/servlet to do the logic on the
validating then on the
input jsp.it must forward to your input form jsp so
you can repopulate the values of the fields.. you can
have the following codes:
validator.jsp:
//validate here
<%if(success){%>
<jsp:forward page="success.jsp"/>
<%}else{%>
<jsp:forward page="input.jsp?err=error"/>
<%}%>input.jsp
<%
String err =
request.getParameter("err")!=null?request.getParameter
("err"):"none";
String field1 =
request.getParameter("feild1")!=null?request.getParame
ter("feild1"):"";
if(!err.equals("none")){
%>
<%=err%>
<%}%>
<input type="text" value="<%=field1%>"
name="feild1"/>
Raw scriptlet code? When you could and should be using JSTL? Bad idea.
%

Similar Messages

  • How to do  validation in jsp using javascript

    how to do validation in jsp using javascript

    The same way you do with any HTML page.
    Catch the onclick/onsubmit event, do your validation in javascript and then allow/cancel the action as required.
    However this is javascript validation only - javascript can never call JSP code.

  • "getting a javascript error while validating a JSP"

    Hi folks,
    Someone help me out with this problem.
    I am getting a javascript validation error when I am trying to validate a JSP.
    if(eval("document.frmAdminSowAssignValues.chkSowEmployee"+i).checked)
    If I try to load a JSP page on a browser, it is giving a javascript error as
    "'checked' is null or not a object".
    Thanks.

    Hi Manoj,
    Thanks for posting here.
    I suggest you to clear all cookies and restart your IE. Let us know the results.
    Also, I suggest you to try lauching Azure portal on a different browsers such as Firefox, Safari etc.
    Girish Prajwal

  • STRUTS: client-side validation in jsp using  DynaValidatorForm

    I am supposed to work on struts on as project and it is like learning a crash course and work the next day.
    In Struts 1.1 enviroment, I am using DynaValidatorForm to create a bean form and then perform validation.
    1. I write a DynaValidatorForm definition in struts-config.xml
    2. I write xml for action so that when /getQuotes.do in invoked by a jsp form, the form data is put into the QuoteDetailsBean.
    3. add the plugin script for ValidatorPlugIn
    xml fragment from struts-config:
    //form bean
    <form-beans>
    <form-bean name="QuoteDetailsBean" type="org.apache.struts.validator.DynaValidatorForm">
        <form-property name="forename" type="java.lang.String"/>
       <form-property name="surname" type="java.lang.String"/>
    <form-bean>
    </form-beans>
    <action
            path="/getQuotes"
            type="com.kainos.quickquotes.struts.QQGetQuotesAction"
            validate="true"
            name="QuoteDetailsBean"
            input="/userform1.do"
            parameter="save"
            scope="session">
            <forward name="success" path="/pages/jsp/result.jsp"/>
            <forward name="back" path="/userform1.do"/>
    </action>
    <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
         <set-property
             property="pathnames"
             value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
      </plug-in>Now I write a validation code for getQuotes.do. note that I can write the validation code with
    <form name="QuoteDetailsBean"> but this form bean is shared by many jsp, so i am using the name of the action
    (getQuotes) as the name of the form in the validation.xml.
    So far this looks okay, as I am going by some example.
    xml fragment from validation.xml:
    <formset>
              <form name="/getQuotes">
                 <field property="forename" depends="required,minlength">
                    <arg0 key="QuoteDetailsBean.forename" />
                    <arg1 name="minlength" key="${var:minlength}" resource="false"/>
                    <var>
                       <var-name>minlength</var-name>
                       <var-value>2</var-value>
                    </var>
                 </field>
                 <field property="surname" depends="required,minlength">
                <arg0 key="QuoteDetailsBean.surname" />
                <arg1 name="minlength" key="${var:minlength}" resource="false"/>
                <var>
                   <var-name>minlength</var-name>
                   <var-value>2</var-value>
                </var>
                 </field>
    </formset>Now I write the JSP. I use the <html:javascript> tag to allow front-end validation based on the xml in validation.xml.
    The jsp code:
    <%@ taglib uri="/tags/struts-bean" prefix="bean" %>
    <%@ taglib uri="/tags/struts-html" prefix="html" %>
    <%@ taglib uri="/tags/struts-logic" prefix="logic" %>
    <html:html locale="true">
    <head>
    <title><bean:message key="welcome.title"/></title>
    <html:base/>
    <html:javascript formName="/getQuotes"
                method="validateForm"
                dynamicJavascript="true"
                staticJavascript="false"
                cdata="false" />
    </head>
    <body bgcolor="#FFCC9F">
    <html:errors />
    <html:form action="getQuotes.do" onsubmit="return validateForm(this);" >
    Forename:</td> <td>���<html:text property="forename"/></td></tr>
    <tr> <td>Surname:</td> <td>���<html:text property="surname"/></td></tr>
    <html:submit value="Quotes" /></td></tr>
    </html:form>
    </body>
    </html:html>Does this looks okay. I wrote so far based on some tutorials n help online.
    Now when I open the JSP and then do a submit, there is no validation (I tried by submitting with empty forename and surname. I mean i could invoke the action class and the invoke class
    redirects(forwards) to the appropriate path. so the code works fine except validation is not done
    Q1. So what should i do more to get client-side validation?
    What actually happens in client-side validation? does a pop up alert appears?
    nothing happens so far in my case.
    Q2. What should I do more for server side validation. Since the form is incomplete, what happens?
    I thought the same form returns and the error messages are printed in the jsp page since i have the <html:errors />
    tag just below the <body> tag.
    The action class is pretty simple so far:
    public class QQGetQuotesAction extends Action {
        public QQGetQuotesAction(){
    public ActionForward execute(ActionMapping mapping,
                 ActionForm form,
                 HttpServletRequest request,
                 HttpServletResponse response)
        throws Exception {
            DynaValidatorForm dynaform = (DynaValidatorForm)form;
            System.out.println("forename:"+dynaform.get("forename");
            System.out.println("surname:"+dynaform.get("surname");
            return forward=mapping.findForward("back");
    }Please help me out. I think I am missing something which i need to do
    thanks
    Tanveer

    I think the validations are to be declared on the form
    name and not the action path.
    Your formName is QuoteDetailsBean but your are using
    the action path(/getQuotes) both in the validation
    rules and the jsp tags. Use the formName on both the
    places.
    Also your html:javascript tag will not generate the
    static javascript to validate the fields. For this you
    will have to add code like below.
    <html:javascript dynamicJavascript="false"
    staticJavascript="true"/>
    Other options is to set the attribute
    staticJavascript="true" in your html:javascript tag.
    Hope it helps.hi
    staticJavascript="true" did the trick. :)
    I think the validations are to be declared on the form name and not the action path.It is not necessary. You can declare the validation on the action class. This is essential if a form bean is shared by several JSPs having its own action class. This is as per as I read in a tutorial and it works.

  • How to make the server slide form validation using JSP?

    anyone knows how to do server-side form validation??
    Thanks in advanced

    try this way
         //create a validation java class in that class u create separate methods for validating
         for example if u want to validate that a particular text box should not be empty
         then u can try this way
         say like this
         class ServerValidation()
         boolean message=false;
         public static boolean isTextBoxEmpty(String value)
         if(value.length<1)
         System.out.println("Text box is empty");
         message=false
         else
         message=true
         return message
    now say u r having a html page in which there is a text box on submiting u call say validate.jsp
    in this jsp u write this way
    <%
    String message=request.getParameter("name of ur text box");
    boolean b=ServerValidation.isTextBoxEmpty(message)
    if(b)
    //valid is true do ur other activity
    else
    String messageToUser="Please Enter Some value"
    u can now display this message on jsp and create a back button
    %>
    hope its clear

  • BC4J Entity object validation and JSP

    Hi, I've been trying to implement BC4J best practices as per a previous thread with Steven Muench.
    I've placed all my business logic/validation in the entity object create and validateEntity methods. This works perfectly in the tester utility.
    In a JSP page the first time around the error raised also gets displayed properly prompting the user to go back and fix his data entry. The problem is that the error keeps reappearing even after the data has been fixed.
    We use web beans to perform the save using standard create/setAttribute/InsertRow/commit logic.
    The whole setup works perfectly in JSP if there are no errors in the data.
    Any pointers or ideas?
    Thanks.
    null

    productNew.jsp
    <FORM NAME="saveForm" METHOD=POST ACTION="productSave.jsp">
    <table align="center">
    <tr>
    <td>
    <div align="right">Product Code:</div>
    </td>
    <td>
    <input type="text" name="productcode" size="6" maxlength="6">
    </td>
    </tr>
    <tr>
    <td>
    <div align="right">Product Sname:</div>
    </td>
    <td>
    <input type="text" name="productsname" size="20" maxlength="20">
    </td>
    </tr>
    <tr>
    <td height="19">
    <div align="right">Product Name:</div>
    </td>
    <td height="19">
    <input type="text" name="productname" size="45" maxlength="45">
    </td>
    </tr>
    <tr>
    <td>
    <div align="right">Product Type:</div>
    </td>
    <td>
    <jsp:useBean class="com.palmtreebusiness.edms.products.jsp.LovBean" id="lov1" scope="request">
    <%
    lov1.setLovDefault("None Selected");
    lov1.setLovKey(0);
    lov1.setLovKeyDescription(1);
    lov1.setJSOnChangeMethod("");
    lov1.setLovHTMLField("producttypekey");
    lov1.initialize(pageContext, "productsjsp_com_palmtreebusiness_edms_products_bc4j_bc4jmodule.ProducttypetbView");
    lov1.render();
    %>
    </jsp:useBean> </td>
    </tr>
    <tr>
    <td>
    <div align="right">Product Sub Class:</div>
    </td>
    <td>
    <jsp:useBean class="com.palmtreebusiness.edms.products.jsp.LovBean" id="lov2" scope="request">
    <%
    lov2.setLovDefault("All Selected");
    lov2.setLovKey(0);
    lov2.setLovKeyDescription(1);
    lov2.setJSOnChangeMethod("");
    lov2.setLovHTMLField("productsubclasskey");
    lov2.initialize(pageContext, "productsjsp_com_palmtreebusiness_edms_products_bc4j_bc4jmodule.ProductsubclasstbView");
    lov2.render();
    %>
    </jsp:useBean>
    </td>
    </tr>
    <tr>
    <td>
    <div align="right">STCC DG Code:</div>
    </td>
    <td>
    <input type="text" name="stccdgcodekey" size="10" maxlength="10">
    </td>
    </tr>
    <tr>
    <td>
    <div align="right">Harmonized Code:</div>
    </td>
    <td>
    <input type="text" name="harmonizedcode" size="20" maxlength="20">
    </td>
    </tr>
    </table>
    </form>
    productSave.jsp
    <%@ page language = "java" errorPage="errorpage.jsp" import = "java.util.*, oracle.jbo.*, javax.naming.*, oracle.jdeveloper.html.*, oracle.jbo.html.databeans.*" contentType="text/html;charset=ISO-8859-1"%>
    <%
    // make sure the application is registered
    oracle.jbo.html.jsp.JSPApplicationRegistry.registerApplicationFromPropertyFile(session , "productsjsp_com_palmtreebusiness_edms_products_bc4j_bc4jmodule");
    %>
    <HTML>
    <HEAD>
    <jsp:useBean id="prod" class="com.palmtreebusiness.edms.products.jsp.productSavebean" scope="request">
    <%
    try {
    prod.initialize(pageContext, "productsjsp_com_palmtreebusiness_edms_products_bc4j_bc4jmodule.ProducttbView");
    prod.setReleaseApplicationResources(true);
    prod.save();
    response.sendRedirect("productList.jsp");
    response.setStatus(response.SC_MOVED_TEMPORARILY);
    catch (Exception ex) {
    out.println("<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=ISO-8859-1\">");
    out.println("<META NAME=\"GENERATOR\" CONTENT=\"Oracle JDeveloper\">");
    out.println("<TITLE>");
    out.println("Save Error");
    out.println("</TITLE>");
    out.println("</HEAD>");
    out.println("<BODY>");
    out.println("A save error occured.<br><br>");
    out.println(ex.getMessage());
    out.println("<br><br>Plese use the back feature of your browser to go back to the form and fix your data.");
    out.println("</BODY>");
    out.println("</HTML>");
    %>
    </jsp:useBean>
    saveBean.java
    public void save() throws oracle.jbo.JboException {
    Row rRow;
    System.out.println(request.getParameter("producttypekey"));
    System.out.println(request.getParameter("productsubclasskey"));
    try {
    // get the rowset instance
    RowSet rSet = getRowSet();
    rRow = rSet.createRow();
    rRow.setAttribute("Producttypekey", new Number(request.getParameter("producttypekey")));
    rRow.setAttribute("Productsubclasskey", new Number(request.getParameter("productsubclasskey")));
    rRow.setAttribute("Productcode", request.getParameter("productcode"));
    rRow.setAttribute("Productsname", request.getParameter("productsname"));
    rRow.setAttribute("Productname", request.getParameter("productname"));
    rRow.setAttribute("Stccdgcodekey", new Number(request.getParameter("stccdgcodekey")));
    rRow.setAttribute("Harmonizedcode", request.getParameter("harmonizedcode"));
    rSet.insertRow(rRow);
    rSet.getApplicationModule().getTransaction().commit();
    catch (oracle.jbo.JboException jboex) {
    qView.reset();
    throw new oracle.jbo.JboException(jboex.getMessage());
    catch (Exception ex) {
    throw new oracle.jbo.JboException(ex.getMessage());
    producttbimpl.java
    public void create(AttributeList attributeList) {
    try {
    SequenceImpl s = new SequenceImpl("producttb_seq", getDBTransaction());
    Integer next = (Integer)s.getData();
    setProductkey(new Number(next.intValue()));
    super.create(attributeList);
    catch (Exception jboe) {
    if (jboe instanceof oracle.jbo.JboException) {
    oracle.jbo.JboException ex2 = (oracle.jbo.JboException)jboe;
    if (ex2.getErrorCode().equals("25030")) {
    return;
    throw new oracle.jbo.JboException("Unable to create this record!\n" + jboe.getMessage());
    public void validateEntity() throws oracle.jbo.JboException {
    //TODO: Add custom implementation.
    Number nSubclasskey, nTypekey;
    Number nSubclassFkey, nTypeFkey;
    try {
    nSubclassFkey = getProductsubclasstb().getProductclasskey();
    nTypeFkey = getProducttypetb().getProducttypekey();
    nSubclasskey = getProductsubclasskey();
    nTypekey = getProducttypekey();
    if (!nSubclassFkey.equals(nSubclasskey) &#0124; &#0124; !nTypeFkey.equals(nTypekey)) {
    throw new oracle.jbo.JboException("You need to specify a product sub class and type first!");
    catch (Exception ex) {
    throw new oracle.jbo.JboException("You need to specify a product sub class and type first!");
    super.validateEntity();
    null

  • How to do javascript validation in jsp

    Hi everybody, i have done javascript validation in html but i dont know how to validate this jsp page.
    <%@ page language="java" contentType="text/html;charset=UTF-8"%>
    <%@taglib uri="http://beehive.apache.org/netui/tags-html-1.0" prefix="netui"%>
    <%@taglib uri="http://beehive.apache.org/netui/tags-databinding-1.0" prefix="netui-data"%>
    <%@taglib uri="http://beehive.apache.org/netui/tags-template-1.0" prefix="netui-template"%>
    <netui:html>
         <head>
              <netui:base/>
         </head>
    <netui:body>
    <netui:form action="skippedAccessories">
    <netui:hidden dataSource="actionForm.location.city" dataInput="${request.phoneAccessoriesForm.location.city}"/>
    <netui:hidden dataSource="actionForm.location.state" dataInput="${request.phoneAccessoriesForm.location.state}"/>
    <netui:hidden dataSource="actionForm.location.zip" dataInput="${request.phoneAccessoriesForm.location.zip}"/>
    <netui:hidden dataSource="actionForm.plan.type" dataInput="${request.phoneAccessoriesForm.plan.type}"/>
    <netui:hidden dataSource="actionForm.plan.id" dataInput="${request.phoneAccessoriesForm.plan.id}"/>
    <netui:hidden dataSource="actionForm.plan.title" dataInput="${request.phoneAccessoriesForm.plan.title}"/>
    <netui:hidden dataSource="actionForm.phone.modelID" dataInput="${request.phoneAccessoriesForm.phone.modelID}"/>
    <netui:hidden dataSource="actionForm.phone.modelTitle" dataInput="${request.phoneAccessoriesForm.phone.modelTitle}"/>
    <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="75%">
    <tr>
    <td align="center">
    <netui-data:getData resultId="imageFileName" value="${request.phoneAccessoriesForm.imageFileName}"/>
    <%
    String imageFileName = (String) pageContext.getAttribute("imageFileName");
    String img1 = request.getContextPath() + "/framework/skins/uscc/images/" + imageFileName;
    System.out.println("psAccessories.jsp - img1 = " + img1);
    %>
    <netui:imageButton src="<%=img1%>" onKeyPress="submit"/>
    </td>
    </tr>
    <tr>
    <td align="center">
    <%
    String img2 = request.getContextPath() + "/framework/skins/uscc/images/continue.gif";
    %> Select accessorries for your
    <netui:label value="${request.phoneAccessoriesForm.phone.modelTitle}"/>
    <br>
    ... or continue to checkout
    <netui:imageButton src="<%=img2%>" onKeyPress="submit"/>
    </td>
    </tr>
    <tr>
    <td> </td>
    </tr>
    <tr>
    <td bgcolor="#DAECFB">
    Calling Plan Selected:
    <netui:label value="${request.phoneAccessoriesForm.plan.title}"/>
    </td>
    </tr>
    <tr>
    <td> </td>
    </tr>
    </table>
    </netui:form>
    </netui:body>
    </netui:html>
    Can anybody help me

    So how i can do thisLet's try this again shall we.
    You said you have previously validated HTML with
    JavaScript right?
    Do the same thing. It works exactly the same. Don't
    ask me how when you know how.(..and ask your questions in a java script forum if you have any problems. Java script isn't Java)

  • How to do Front End Validation for JSP Forms using Java Script with 9iJD...

    How to do Front End validation using 9iJD. Any wizard is there. We need to do the val. using Java Script. If its not available, please include that in the Production Release.

    Thanks a lot. When is the Production Release is scheduled. Please tell us whether itll be available for Free Download. Bec, we couldnt buy. Bec, if its working fine with all the options without any bug only, we can ask our company to buy 9iJD by stating the advantages. Just explain us.

  • Script validation in Jsp page

    We have used the following code snippet in my Jsp page.
    window.onbeforeunload = function (evt)
                             var message = 'Waring message';
                             if (typeof evt == 'undefined')
                                  evt = window.event;
                             if (evt && (evt.clientX <0 || evt.clientY <0)) {
                                  return message;
    We introduced this code when the user navigates to other screen without saving current change we wanted to give warning message.
    This is working when the user click back,refresh,front butons and entering new URL in address bar.
    Below address bar we are having menu link(Link Sun forums link avilable below address bar).If the user clicks new menu this event is not capured.Becuase of that we are not getting warning message. Please let me know how to capture that event too..
    Thanks,
    Sujeeth

    As Balus stated, this is not the right forum:)
    You should read about javascript and html, but I'll try to explain very quickly
    1) window is the object representing the page loaded
    2) it has some default event handler, and in javascript you have the right to overwrite them, as you are doing
    3) to bind event handler, in general, you should retrieve a reference to the object in javascript, and then add an event listener. There are some cross-browser compatibilities for that and i suggest you to use Yahoo UI libraries to work that out:)
    Best Regards
    edmondo

  • Input field validation using JSP in HTMLB

    Hi All,
    How can we validate an input field in a form in BSP page.
    Like: There are two input fields in my form.I want the user to enter value in any one and only one of the fields.If the value is entered in both fields or none of the fields the user should get a popup and form  must not be submited.
    Shall i use the onClientClick attribute of Button element or doValidate attribute of Inputfield element or  validationScript attribute of From element?
    Please help.
    Thanks a lot,
    Anubhav.

    Here you go:
    <%@page language="abap" %>
    <%@extension name="htmlb" prefix="htmlb" %>
    <htmlb:content design="design2003" >
      <htmlb:page title=" " >
        <htmlb:form id="form1" >
          < script t-ype = "text/javascript" >     "Remove "-" between t & ype in type
          function checkInput()
           var field1 = document.form1.field1.value;
           var field2 = document.form1.field2.value;
    var error = "";
    if(field1 != "" && field2 != "")
              { error = "X";
                  javascript error message here          }
    if(field1 == "" && field2 ==  "")
              { error = "X";
                                javascript error message here
    if(error == "")
              htmlbSL(this,2,'mybutton:Submit');
          < / script >
              <htmlb:textView text      = "Hello World!"
                              textColor = "RED"
                              design    = "HEADER1"
                              align     = "CENTER" />
              <htmlb:inputField id        = "field1"
                                value     = "<%= var1 %>"
                                type      = "integer"
                                alignment = "CENTER" />
              <htmlb:inputField id        = "field2"
                                value     = "<%= var2 %>"
                                type      = "integer"
                                alignment = "CENTER" />
              <htmlb:button id            = "mybutton"
                            text          = "Press Me"
                            onClientClick = "javascript:checkInput();" />
        </htmlb:form>
      </htmlb:page>
    </htmlb:content>
    Raja T
    Message was edited by:
            Raja Thangamani

  • JSP-VALIDATION

    Pls, I want to do validation with jsp. I want it to return error messages that some data are omitted on the same page with the form submitting, but its not working. pls, assist!. See the code
    <html>
    <body>
    <% String first = request.geParameter(firstname);
        if(first !=null || !first.equals(""))
           // go to another page         
        else
           %>
    Fill in your first name
    <form method="post action="accept.jsp">
    First Name: <input type="text" name="firstname"> <%=first%>
    <input type="submit" value="Submit">
    <%}%>
    </body>
    </html>

    spelling mistake "getparameter"

  • Plz Solve this Error in    " Client Side Address Validation in Struts "

    Hi,
    i have created struts project and foll code is written as foll :
    plz find out error in code :
    struts-config.xml code
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
    <struts-config>
    <data-sources />
    <form-beans >
    <form-bean name="AddressForm" type="com.projectvalidator.form.AddressForm" />
    </form-beans>
    <global-exceptions />
    <global-forwards />
    <action-mappings >
    <action
    input="/validateaddress.jsp"
    name="AddressForm"
    path="/address"
    scope="request"
    validate="true"
    type="com.projectvalidator.action.AddressAction">
    <forward name="success" path="/success.jsp"/>
    <forward name="failure" path="/validateaddress.jsp"/>
    </action>
    </action-mappings>
    <message-resources parameter="MessageResources" />
    <!-- Validator plugin -->
    <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
    <set-property property="pathnames" value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
    </plug-in>
    </struts-config>
    MessageResources.properties file code
    AddressForm.name=Name      
    AddressForm.address=Address
    AddressForm.email=EmailAddress
    validation.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <form-validation>
    <formset>
    <!-- Address form Validation-->
    <form name="AddressForm">
    <field property="name"
    depends="required" >
    <arg key="AddressForm.name"/>
    </field>
    <field property="address"
    depends="required" >
    <arg key="AddressForm.address"/>
    </field>
    <field property="email"
    depends="required" >
    <arg key="AddressForm.email"/>
    </field>
    </form>
    </formset>
    </form-validation>
    validationaddress.jsp
    <%@ page language="java" pageEncoding="UTF-8"%>
    <%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
    <%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
    <%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %>
    <%@ taglib uri="http://jakarta.apache.org/struts/tags-tiles" prefix="tiles" %>
    <%@ taglib uri="http://jakarta.apache.org/struts/tags-template" prefix="template" %>
    <%@ taglib uri="http://jakarta.apache.org/struts/tags-nested" prefix="nested" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html:html locale="true">
    <head>
    <html:base />
    <title>validateaddress.jsp</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    </head>
    <body bgcolor=#fdffca>
    <html:form action="/address" method="post" onsubmit="return validateAddressForm(this);">
    <p>
    <html:errors/><p>
    name : <html:text property="name" size="30" maxlength="30" />
    address : <html:text property="address" size="30" maxlength="30" />
    emailaddress : <html:text property="email" size="30" maxlength="30" />
    <html:submit>Submit</html:submit>
    <html:cancel>Cancel</html:cancel>
    <!-- Begin Validator Javascript Function-->
    <html:javascript formName="AddressForm"/>
    <!-- End of Validator Javascript Function-->
              </html:form>
         </body>
    </html:html>
    AddressForm.java
    //Created by MyEclipse Struts
    // XSL source (default): platform:/plugin/com.genuitec.eclipse.cross.easystruts.eclipse_3.9.210/xslt/JavaClass.xsl
    package com.projectvalidator.form;
    import org.apache.struts.validator.ValidatorForm;
    * MyEclipse Struts
    * Creation date: 02-23-2006
    * XDoclet definition:
    * @struts:form name="AddressForm"
    public class AddressForm extends ValidatorForm {
         // --------------------------------------------------------- Instance Variables
         /** address property */
         private String address;
         /** emailaddress property */
         private String email;
         /** name property */
         private String name;
         // --------------------------------------------------------- Methods
         * Returns the address.
         * @return String
         public String getAddress() {
              return address;
         * Set the address.
         * @param address The address to set
         public void setAddress(String address) {
              this.address = address;
         * Returns the emailaddress.
         * @return String
         public String getEmail() {
              return email;
         * Set the emailaddress.
         * @param emailaddress The emailaddress to set
         public void setEmail(String email) {
              this.email = email;
         * Returns the name.
         * @return String
         public String getName() {
              return name;
         * Set the name.
         * @param name The name to set
         public void setName(String name) {
              this.name = name;
    AddressAction.java
    //Created by MyEclipse Struts
    // XSL source (default): platform:/plugin/com.genuitec.eclipse.cross.easystruts.eclipse_3.9.210/xslt/JavaClass.xsl
    package com.projectvalidator.action;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import org.apache.struts.action.Action;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionForward;
    import org.apache.struts.action.ActionMapping;
    import com.projectvalidator.form.AddressForm;
    * MyEclipse Struts
    * Creation date: 02-23-2006
    * XDoclet definition:
    * @struts:action path="/address" name="AddressForm" input="/validateaddress.jsp" scope="request" validate="true"
    * @struts:action-forward name="success" path="success.jsp" redirect="true"
    * @struts:action-forward name="failure" path="validateaddress.jsp" redirect="true"
    public class AddressAction extends Action {
         // --------------------------------------------------------- Instance Variables
         // --------------------------------------------------------- Methods
         * Method execute
         * @param mapping
         * @param form
         * @param request
         * @param response
         * @return ActionForward
         public ActionForward execute(
              ActionMapping mapping,
              ActionForm form,
              HttpServletRequest request,
              HttpServletResponse response) {
              AddressForm AddressForm = (AddressForm) form;
              // TODO Auto-generated method stub
              //String forward="";
              //if (AddressForm.getName().equalsIgnoreCase("admin"));
              //return mapping.findForward(forward);
              return null;
    ==========================================
    PLZ REPLY ME ANYONE , I AM NOT GETTING OUTPUT , i am using jboss application server, i am getting a pop-up window as below:
    null is required
    null is required
    null is required
    i hope any one replies me

    Hi,
    i have created struts project and foll code is written as foll :
    plz find out error in code :
    struts-config.xml code
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
    <struts-config>
    <data-sources />
    <form-beans >
    <form-bean name="AddressForm" type="com.projectvalidator.form.AddressForm" />
    </form-beans>
    <global-exceptions />
    <global-forwards />
    <action-mappings >
    <action
    input="/validateaddress.jsp"
    name="AddressForm"
    path="/address"
    scope="request"
    validate="true"
    type="com.projectvalidator.action.AddressAction">
    <forward name="success" path="/success.jsp"/>
    <forward name="failure" path="/validateaddress.jsp"/>
    </action>
    </action-mappings>
    <message-resources parameter="MessageResources" />
    <!-- Validator plugin -->
    <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
    <set-property property="pathnames" value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
    </plug-in>
    </struts-config>
    MessageResources.properties file code
    AddressForm.name=Name      
    AddressForm.address=Address
    AddressForm.email=EmailAddress
    validation.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <form-validation>
    <formset>
    <!-- Address form Validation-->
    <form name="AddressForm">
    <field property="name"
    depends="required" >
    <arg key="AddressForm.name"/>
    </field>
    <field property="address"
    depends="required" >
    <arg key="AddressForm.address"/>
    </field>
    <field property="email"
    depends="required" >
    <arg key="AddressForm.email"/>
    </field>
    </form>
    </formset>
    </form-validation>
    validationaddress.jsp
    <%@ page language="java" pageEncoding="UTF-8"%>
    <%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
    <%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
    <%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %>
    <%@ taglib uri="http://jakarta.apache.org/struts/tags-tiles" prefix="tiles" %>
    <%@ taglib uri="http://jakarta.apache.org/struts/tags-template" prefix="template" %>
    <%@ taglib uri="http://jakarta.apache.org/struts/tags-nested" prefix="nested" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html:html locale="true">
    <head>
    <html:base />
    <title>validateaddress.jsp</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    </head>
    <body bgcolor=#fdffca>
    <html:form action="/address" method="post" onsubmit="return validateAddressForm(this);">
    <p>
    <html:errors/><p>
    name : <html:text property="name" size="30" maxlength="30" />
    address : <html:text property="address" size="30" maxlength="30" />
    emailaddress : <html:text property="email" size="30" maxlength="30" />
    <html:submit>Submit</html:submit>
    <html:cancel>Cancel</html:cancel>
    <!-- Begin Validator Javascript Function-->
    <html:javascript formName="AddressForm"/>
    <!-- End of Validator Javascript Function-->
              </html:form>
         </body>
    </html:html>
    AddressForm.java
    //Created by MyEclipse Struts
    // XSL source (default): platform:/plugin/com.genuitec.eclipse.cross.easystruts.eclipse_3.9.210/xslt/JavaClass.xsl
    package com.projectvalidator.form;
    import org.apache.struts.validator.ValidatorForm;
    * MyEclipse Struts
    * Creation date: 02-23-2006
    * XDoclet definition:
    * @struts:form name="AddressForm"
    public class AddressForm extends ValidatorForm {
         // --------------------------------------------------------- Instance Variables
         /** address property */
         private String address;
         /** emailaddress property */
         private String email;
         /** name property */
         private String name;
         // --------------------------------------------------------- Methods
         * Returns the address.
         * @return String
         public String getAddress() {
              return address;
         * Set the address.
         * @param address The address to set
         public void setAddress(String address) {
              this.address = address;
         * Returns the emailaddress.
         * @return String
         public String getEmail() {
              return email;
         * Set the emailaddress.
         * @param emailaddress The emailaddress to set
         public void setEmail(String email) {
              this.email = email;
         * Returns the name.
         * @return String
         public String getName() {
              return name;
         * Set the name.
         * @param name The name to set
         public void setName(String name) {
              this.name = name;
    AddressAction.java
    //Created by MyEclipse Struts
    // XSL source (default): platform:/plugin/com.genuitec.eclipse.cross.easystruts.eclipse_3.9.210/xslt/JavaClass.xsl
    package com.projectvalidator.action;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import org.apache.struts.action.Action;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionForward;
    import org.apache.struts.action.ActionMapping;
    import com.projectvalidator.form.AddressForm;
    * MyEclipse Struts
    * Creation date: 02-23-2006
    * XDoclet definition:
    * @struts:action path="/address" name="AddressForm" input="/validateaddress.jsp" scope="request" validate="true"
    * @struts:action-forward name="success" path="success.jsp" redirect="true"
    * @struts:action-forward name="failure" path="validateaddress.jsp" redirect="true"
    public class AddressAction extends Action {
         // --------------------------------------------------------- Instance Variables
         // --------------------------------------------------------- Methods
         * Method execute
         * @param mapping
         * @param form
         * @param request
         * @param response
         * @return ActionForward
         public ActionForward execute(
              ActionMapping mapping,
              ActionForm form,
              HttpServletRequest request,
              HttpServletResponse response) {
              AddressForm AddressForm = (AddressForm) form;
              // TODO Auto-generated method stub
              //String forward="";
              //if (AddressForm.getName().equalsIgnoreCase("admin"));
              //return mapping.findForward(forward);
              return null;
    ==========================================
    PLZ REPLY ME ANYONE , I AM NOT GETTING OUTPUT , i am using jboss application server, i am getting a pop-up window as below:
    null is required
    null is required
    null is required
    i hope any one replies me

  • Problem in struts validation

    hi,
    i am doing a project using struts framework.
    i've configured strtus-config.xml , validation.xml
    but validation framework is not working for me.
    when i click submitt button without entering any values, it directly maps to the success page. but it should show the errors.
    i've attached all the files with this. plz give me the solution
    struts-config.xml
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <struts-config>
    <form-beans>
    <form-bean name="allotIssueFormBean" type="issues.AllotIssueFormBean"/>
    </form-beans>
    <action-mappings>
    <action path="/allotIssue"
    type="issues.AllotIssueAction"
    scope="request"
    name="allotIssueFormBean"
    validate="true"
    input="/allotIssue.jsp">
    <forward name="success"
    path="/results/success.jsp"/>
    </action>
    </action-mappings>
    <message-resources parameter="MessageResources" />
    <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
    <set-property property="pathnames" value="/WEB-INF/validator-rules.xml,/WEB-INF/validator/validation.xml" />
    <set-property property="stopOnFirstError" value="true" />
    </plug-in>
    </struts-config>
    -- validation.xml --
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <!DOCTYPE form-validation PUBLIC
    "-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.1.3//EN"
    "http://jakarta.apache.org/commons/dtds/validator_1_1_3.dtd">
    <form-validation>
    <!--
    This is a minimal Validator form file with a couple of examples.
    -->
    <global>
    <!-- An example global constant
    <constant>
    <constant-name>postalCode</constant-name>
    <constant-value>^\d{5}\d*$</constant-value>
    </constant>
    end example-->
    </global>
    <formset>
    <!-- An example form -->
    <form name="AllotIssueFormBean">
    <field
    property="issueID"
    depends="required" >
    <arg0 key="ddd" resource="false"/>
    </field>
    <field
    property="listName"
    depends="required">
    <arg0 key="ddd"/>
    </field>
    <field
    property="projectName"
    depends="required">
    <arg0 key="ddd"/>
    </field>
    <field
    property="selectAllotting"
    depends="required">
    <arg0 key="ddd"/>
    </field>
    <field
    property="selectDate"
    depends="required">
    <arg0 key="ddd"/>
    </field>
    <field
    property="selectMonth"
    depends="required">
    <arg0 key="ddd"/>
    </field>
    <field
    property="selectYear"
    depends="required">
    <arg0 key="ddd"/>
    </field>
    </form>
    </formset>
    </form-validation>
    allotIssue.jsp
    <%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    <%@ taglib uri="/tags/struts-bean" prefix="bean" %>
    <%@ taglib uri="/tags/struts-html" prefix="html" %>
    <%@ taglib uri="/tags/struts-logic" prefix="logic" %>
    <html:html>
    <head>
    <TITLE> ALLOTT ISSUE </TITLE>
    <html:javascript formName="allotIssueFormBean" staticJavascript="true" method="validateAllotIssueFormBean"/>
    <STYLE>
    body{
    font-family:verdana;
    background-color:#0111d3;
    color:white;
    font-size:8px;
    table
    font-size:10px;
    </STYLE>
    </head>
    <html:errors/>
    <html:form action="/allotIssue.do" >
    <TABLE border="1" align="center" bodercolor="silver" bgcolor='#4478f0' width="40%">
    <tr>
    <td colspan="2" style='border:0px' align="center">ALLOT ISSUE</td>
    </tr>
    <TR style='border:0px'>
    <TD>IssueID:</TD>
    <TD><html:text property="issueID"/></TD>
    </TR>
    <TR style='border:0px'>
    <TD>List Name:</TD>
    <TD><html:text property="listName"/></TD>
    </TR>
    <TR style='border:0px'>
    <TD>Project Name:</TD>
    <TD><html:text property="projectName"/></TD>
    </TR>
    <TR style='border:0px'>
    <TD>Allotted To:</TD>
    <TD><html:select property="selectAllotting" >
    <html:option value="associatename1">Name1</html:option>
    <html:option value="associateName2">Name2</html:option>
    <html:option value="associatename3">Name3</html:option>
    </html:select>
    </TD>
    </TR>
    <TR CLASS="tr">
    <TD CLASS="td" style='border:0px'>Projected-End-Date</td>
    <TD><html:select property="selectDate" >
    <html:option value="1">1</html:option>
    <html:option value="2">2</html:option>
    <html:option value="3">3</html:option>
    </html:select>
    <html:select property="selectMonth" >
    <html:option value="1" >Jan</html:option>
    <html:option value="2" >Feb</html:option>
    </html:select>
    <html:select property="selectYear">
    <html:option value="1990">1990</html:option>
    <html:option value="1991">1991</html:option>
    </html:select>
    </TD>
    </TR>
    <TR style='border:0px'>
    <TD colspan="2" align="center">
    <html:submit value="AllotIssue"/>
    <html:reset value="Reset"/>
    </TD>
    </TR>
    </TABLE>
    </html:form>
    </html:html>
    -- AllotIssueAction.java --
    * AllotIssueAction.java
    * Created on April 27, 2006, 4:49 PM
    * To change this template, choose Tools | Options and locate the template under
    * the Source Creation and Management node. Right-click the template and choose
    * Open. You can then make changes to the template in the Source Editor.
    package issues;
    import javax.servlet.http.*;
    import org.apache.struts.action.*;
    public class AllotIssueAction extends Action {
    public ActionForward execute(ActionMapping mapping,
    ActionForm form,
    HttpServletRequest request,
    HttpServletResponse response)
    throws Exception {
    return(mapping.findForward("success"));
    -- AllotIssueFormBean --
    package issues;
    import javax.servlet.http.*;
    import org.apache.struts.action.*;
    import org.apache.struts.validator.*;
    public class AllotIssueFormBean extends ValidatorForm {
    private String issueID = "";
    private String listName = "";
    private String projectName = "";
    private String selectAllotting = "";
    private String selectDate="";
    private String selectMonth="";
    private String selectYear="";
    public String getIssueID() {
    return(issueID);
    public void setIssueID(String issueID) {
    this.issueID = issueID;
    public String getListName() {
    return(listName);
    public void setListName(String listName) {
    this.listName = listName;
    public String getProjectName() {
    return(projectName);
    public void setProjectName(String projectName) {
    this.projectName = projectName;
    public String getSelectAllotting() {
    return(selectAllotting);
    public void setSelectAllotting(String selectAllotting) {
    this.selectAllotting = selectAllotting;
    public String getSelectDate() {
    return(selectDate);
    public void setSelectDate(String selectDate) {
    this.selectDate = selectDate;
    public String getSelectMonth() {
    return(selectMonth);
    public void setSelectMonth(String selectMonth) {
    this.selectMonth = selectMonth;
    public void setSelectYear(String selectYear) {
    this.selectYear = selectYear;
    public String getSelectYear() {
    return(selectYear);
    }

    In the following code...
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <struts-config>
    <form-beans>
    <form-bean name="allotIssueFormBean" type="issues.AllotIssueFormBean"/>
    </form-beans>... should the <form-bean> type attribute be org.apache.struts.validator.DynaValidatorForm? I've only done validation in this way (though I'm still a novice myself). Then you wouldn't need your allotIssueFormBean, and instead you would define the properties in the struts-config using...
    <form-bean ...>
      <form-property name="issueID" type="java.lang.String" />
      <form-property name="listName" type="java.lang.String" />
    ... etc...
    </form-bean>

  • JSP 2.0 XSD

    Hi all,
    I want to edit JSP(X) 2.0 pages with an XML editor, but i can't find de schema definition file.
    I found only the XSD for the 1.2 version of JSP and for de webapp deployment descriptor's JSP 2.0 part at http://java.sun.com/xml/ns/j2ee.
    Thank's by advance,
    Laurent

    Short answer: there isn't one. Quotes from JSP 2.0 spec:
    "JSP 2.0 requires only DTD validation for JSP Documents; containers should
    not perform validation based on other types of schemas, such as XML schema."
    "The current specification only requires DTD validation support for JSP documents.
    A more flexible schema language, like XML Schema, could be useful and
    could be explored by a future version of the JSP specification."
    So no XSD.
    From the wording, one might be forgiven for thinking that at least a DTD exists for JSP 2.0. Again, there is not.
    Relevant Sun resources:
    DTD/XSD for J2EE 1.3:
    http://java.sun.com/dtd/
    DTDs and XSD are available for JSP 1.2.
    DTD/XSD for J2EE 1.4:
    http://java.sun.com/xml/ns/j2ee/
    Validation is only given for descriptors.
    Very disappointing on the whole.
    - Aaron Bell

  • Date validation question

    Hey all,
    I have a form which allows the user to select a month, day, and year for an order. Each (mm/dd/yyyy) are individual menu selects.
    Is there a way to validate that what they enter is greater than today's date? I might be able to do this with javascript but if there is a way to do it with jsp, that'd be great.
    thanks!!!

    HI,
    U can use the SimpleDateFormat for the date validation in JSP or servlets.
    This SimpleDateFormat gives a easy methods to date-validations.
    Regards
    Madhavan C

Maybe you are looking for

  • How can I prevent a memory flow error from occuring when using 3D contour plots?

    After displaying a single contour plot a number of times, LabVIEW crashes and reports a memory overflow error.  I only load a single 2D array, never storing previouls ones. I always index the data for contour plot 0, and don't explicitly store multip

  • Missing (most, but not all) masters from managed project

    I just found that I have a one project in my library where most of the raw master files (NEF) are missing. The project contains 160 photos, but only 14 masters are present and these are randomly distributed in the project (not sequential files). My e

  • How to send two different IDocs to SAP without BPM

    Hi Experts, I am working on jms to IDoc scneario,my requirement is to convert one JMS messge in to 2 IDocs(DELVRY,MATMAS) to ECC , i searched in SDN to achieve this requirement without BPM, i found one blog,but its saying its not possible to use mult

  • Timezone in .ics invitation incorrectly taken into iCal

    Hello, With my iPad I receive .ics calender invitations. The invitations that I send from my company computer to my iPad are all 6 hours off. So I receive an invitation for a meeting 2-3pm EST and it displays at 8-9pm in my iPad when I am about to ac

  • WDS, Ethernet Bridging and 5GHz.

    Hi, I have a dual-band Time Capsule as well as a new Airport Extreme. Also, the two laptops to connect to this are new-model MBAs, so I believe all devices I have should be capable to handle 5 GHz, which I would prefer due to the congestion of the 2.