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

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -