java - <form action="/sampleServlet" giving me exception -


in jsp if call <form action="/sampleservlet" method="get" name="form1">, following exception :

http 404 error--sampleservlet not found.i set sampleservlet in web.xml file , url-pattern set /sampleservlet.

why getting 404 (not found servlet.)?

when using url in html, without leading / relative current url (ie current page displayed). leading / relative website root :

<form action="/context-path/sampleservlet"> 

or

<form action="sampleservlet"> 

will want.

i suggest add context inside action path dynamically. example (in jsp) :

<form action="${pagecontext.request.contextpath}/sampleservlet"> 

with never have change path, example, if move file or copy code, or rename context!


Comments

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -