You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by JB MORLA <jb...@gmail.com> on 2014/02/12 21:10:05 UTC

Test to display an empty form by servlet.

If there is a field called "username", in a form with url "registration" ,
how can I display the form the first time in Tomcat 7? (When the field is
empty)

Re: Test to display an empty form by servlet.

Posted by JB MORLA <jb...@gmail.com>.
I got it to run in Eclipse Juno.

I see that the controller servlet does not mind get-ting an empty field:

        modelBean.setFirstName(request.getParameter("first_name"));

I think the manual gets in trouble because it wants to validate fields like
email or telephone, then redisplay the same form, with the values, plus
error messages.

I'll try to edit the simple-mvc project to do just that.

Many thanks.




On Thu, Feb 13, 2014 at 9:39 AM, Leo Donahue <do...@gmail.com> wrote:

> On Wed, Feb 12, 2014 at 2:23 PM, JB MORLA <jb...@gmail.com> wrote:
> > The purpose of this manual is to demonstrate MVC. In that case, the first
> > component that runs is the Controller, that is the servlet.
> > If I display an html form that redirects to the jsp, it's the html form
> > that has the control.
>
> You are missing some parts to this.
>
> Start here:  http://simple.souther.us/ar01s05.html
>
> Either deploy the .war file to Tomcat or change it to a .zip and
> explore the contents.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: Test to display an empty form by servlet.

Posted by Leo Donahue <do...@gmail.com>.
On Wed, Feb 12, 2014 at 2:23 PM, JB MORLA <jb...@gmail.com> wrote:
> The purpose of this manual is to demonstrate MVC. In that case, the first
> component that runs is the Controller, that is the servlet.
> If I display an html form that redirects to the jsp, it's the html form
> that has the control.

You are missing some parts to this.

Start here:  http://simple.souther.us/ar01s05.html

Either deploy the .war file to Tomcat or change it to a .zip and
explore the contents.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Test to display an empty form by servlet.

Posted by JB MORLA <jb...@gmail.com>.
The purpose of this manual is to demonstrate MVC. In that case, the first
component that runs is the Controller, that is the servlet.
If I display an html form that redirects to the jsp, it's the html form
that has the control.


On Wed, Feb 12, 2014 at 10:18 PM, JB MORLA <jb...@gmail.com> wrote:

> Here is the code I found in a manual written at the time of Tomcat 6:
>
> The code belongs to a servlet. There is no index.jsp file nor order.html
> file.
>
> String message;
>         /*
>          * Initializing the message to display : If one of the mandatory
> fields
>          * is not filled, then we display an error message
>          * else we display a success message
>          */
>         if ( name.trim().isEmpty() || address.trim().isEmpty() ||
> telephone.trim().isEmpty() || amount == -1 ) {
>             message = "Error - You did not fill all the mandatory fields.
> <br> <a href=\"createOrder.jsp\">Click here/a> to access the order form.";
>         } else {
>             message = "Order successfuly created !";
>         }
>
> So when I run the project with Tomcat 7 as target, the url :
> "createOrder.jsp" points to an empty form the first time.
> But Tomcat 7 returns an error stating that it can't find the jsp.
> If I comment out the if.. else test and add some pipes with afile.html and
> index.jsp, the application works.
> I don't know how to replace the test for Tomcat 7
> I'll try to give "name" a value like "ZZZZZ" and test it as you advise.
>
>
> On Wed, Feb 12, 2014 at 9:32 PM, Leo Donahue <do...@gmail.com> wrote:
>
>> On Wed, Feb 12, 2014 at 1:10 PM, JB MORLA <jb...@gmail.com> wrote:
>> > If there is a field called "username", in a form with url
>> "registration" ,
>> > how can I display the form the first time in Tomcat 7? (When the field
>> is
>> > empty)
>>
>>  initialize the username property?
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>

Re: Test to display an empty form by servlet.

Posted by JB MORLA <jb...@gmail.com>.
Here is the code I found in a manual written at the time of Tomcat 6:

The code belongs to a servlet. There is no index.jsp file nor order.html
file.

String message;
        /*
         * Initializing the message to display : If one of the mandatory
fields
         * is not filled, then we display an error message
         * else we display a success message
         */
        if ( name.trim().isEmpty() || address.trim().isEmpty() ||
telephone.trim().isEmpty() || amount == -1 ) {
            message = "Error - You did not fill all the mandatory fields.
<br> <a href=\"createOrder.jsp\">Click here/a> to access the order form.";
        } else {
            message = "Order successfuly created !";
        }

So when I run the project with Tomcat 7 as target, the url :
"createOrder.jsp" points to an empty form the first time.
But Tomcat 7 returns an error stating that it can't find the jsp.
If I comment out the if.. else test and add some pipes with afile.html and
index.jsp, the application works.
I don't know how to replace the test for Tomcat 7
I'll try to give "name" a value like "ZZZZZ" and test it as you advise.


On Wed, Feb 12, 2014 at 9:32 PM, Leo Donahue <do...@gmail.com> wrote:

> On Wed, Feb 12, 2014 at 1:10 PM, JB MORLA <jb...@gmail.com> wrote:
> > If there is a field called "username", in a form with url "registration"
> ,
> > how can I display the form the first time in Tomcat 7? (When the field is
> > empty)
>
>  initialize the username property?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: Test to display an empty form by servlet.

Posted by Leo Donahue <do...@gmail.com>.
On Wed, Feb 12, 2014 at 1:10 PM, JB MORLA <jb...@gmail.com> wrote:
> If there is a field called "username", in a form with url "registration" ,
> how can I display the form the first time in Tomcat 7? (When the field is
> empty)

 initialize the username property?

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org