• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

problem in form action tag

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can any one tell me how to put servlet path in tomcat 5 in html form action tag when calling that servlet by submit action.
i m writing like this <form action="/loginservlet" method=POST> but it is not working as class file is in the classes folder.
Asif.
 
Sheriff
Posts: 67754
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What mapping did you specify in the deployment descriptor?
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Lala Asif Allana:
...
i m writing like this <form action="/loginservlet" method=POST>
Asif.



First, as Bear has asked, show us what you're using for a mapping in your deployment descriptor.

One you have a mapping that you know works (test by typing the URL into your browser's address window) then test your form action attribute.

I can say that building a relative link the way that you did is almost always wrong for a Java Web App. Your link will only work if your app is the default or root app in your container. Either make your link completely relative by removing the preceding slash (also not the best way) or, read the context path from the request object to build your link so that it is relative to the root of your web application.

Example:



Or if you're not using a JSP 2.0 compliant container:
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic