Avatar of aman0711
aman0711
 asked on

Simple HTML form submission not working.

Hi Experts,

                    I have a very simple form, which I am trying to submit. for some reason nothing is executing on click of submit.

                    I do have the associated servlet called "Tracking" (Defined in web.xml as well).

                   what am I doing wrong?
<form method="post" action="/Tracking">
    <table border="1" width="400">
          
       <tr>
          <td width="175"><strong>From:&nbsp;</strong><input type="text"size="12" id="from" name="from" style="margin-top:-12px;"/> </td>
          <td width="50"></td>
          <td width="175"><strong>To:&nbsp;</strong><input type="text" size="12" id="to" name="to" style="margin-top:-12px;"/> </td>
       </tr>
       
       <tr>
          <td></td>
          <td></td>
          <td><input type="button" name="SbmBtn" value="submit" style="margin-left: 85px"/> </td>
       </tr>   
    
    </table>
 </form>

Open in new window

Java EEJSPJava

Avatar of undefined
Last Comment
aman0711

8/22/2022 - Mon
SOLUTION
vijuks

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
ASKER CERTIFIED SOLUTION
Murali Murugesan

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
aman0711

ASKER
Hi Murali,

                 Thanks :-) you fixed it :)

                Now the button is at least working. Murali when I clicked on submit button, it ddi transfer the control but in the address bar I am seeing:

 http://localhost:9080/Tracking , shouldnt this be  http://localhost:9080/si2/Tracking

where si2 is my app name.


Murali Murugesan

yes you are correct.

If you use jsp append <%=request.getContextPath()%>/servletName.

aman0711

ASKER
Yes its a jsp.

so you want to me to fill in something like this:

 <form method="post" action="<%=request.getContextPath()%>/Tracking">
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
Murali Murugesan

yes, tats right
aman0711

ASKER
Cool.. That worked.
I will open another question, with some servlet info Murali :-)

one last question... Where ever I read online, people say that never put Scriptlets in your jsp.

apending <%=request.getContextPath()%> for context root is a common practice?
SOLUTION
Murali Murugesan

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
aman0711

ASKER
Absolutely Murali.

 Thanks for your help :-)

Please help me out with another servlet question, if you are going to stay up for some more time :)


⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
aman0711

ASKER
Thanks :)