java - <form action="/sampleServlet" giving me exception -
this question has answer here:
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
Post a Comment