java - How to configure and where to put a servlet in NetBeans 7.4 accepting parameters from a .jsp page? -
i have worked tomcat
don't know how configure , put servlet
want accept parameters .jsp
page further processing. indicating actual file system path in "action" tag results in "resource not available"
or "not found"
. how should configure servlet
including "action" element in .jsp
, web.xml
, file system? thank you.
a jsp servlet too, , hence forward servlet. (normally other way round, servlet controller, preparing data model request attribute , forwarding jsp view displaying data.)
the servlet defined in web.xml servlet mapping. if use annotations instead mapping similar.
<% request.setattribute("answer", "42"); requestdispatcher rd = request.getrequestdispatcher("/myservlet"); rd.forward(request, response); return; // no output jsp %>
in above "/myservlet" correspond servlet mapping. forwarding not go browser, leaves servlet forwarded to.
you may alternatively redirect servlet. means going browser calls servlet's url.
response.sendredirect(response.encoderedirecturl(redirect));
though looking more circumstantial, used prevent user navigating on posted form, submitting form twice.
if question relates file paths. request.getservletcontext().getrealpath("/css/styles.css")
normal way receive file system paths.
in netbeans 1 makes web-project generating .war deploy, , servlets may reside in package like. web-inf/web.xml traditional minded, annotations in servlet class otherwise.
Comments
Post a Comment