Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Servlet Definition

  Asked By: Leon    Date: Jul 05    Category: Java    Views: 917
  

I've writen a jsp that owns a form. This form's asction,as I want,is a
servlet that I've written,introduced-I mean the mapping in the web.xml
of my Tomcat- and compiled and put into WEB_INF/classes.
My jsp page cannot find this servlet when trying to reach it after
clicking a button on it.
The message is: "The requested resource (/users/login) is not
available.", where (/users/login) is the url-pattern in mt web.xml.
I need urgent help please, waiting for my friends' calls.

Share: 

 

3 Answers Found

 
Answer #1    Answered By: Burkett Bernard     Answered On: Jul 05

please pay attention to your web.xml when config mapping  to it
you should specify complete address in mapping not /user.*
try it.

 
Answer #2    Answered By: Perdita Lopez     Answered On: Jul 05

In here you can find  one sample :


web.xml
<servlet>
<servlet-name>FrontServlet</servlet-name>
<servlet-class>ir.nsy.dlib.com.frontcontroller.FrontServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>FrontServlet</servlet-name>
<url-pattern>/frontServlet</url-pattern>
</servlet-mapping>

the code of servlet
public class FrontServlet extends HttpServlet {
//private static final String CONTENT_TYPE = "text/html; charset=windows-1252";

public void init(ServletConfig config) throws ServletException {
super.init(config);
}

public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
processRequest(request , response);
try {
RequestContext ctx = new RequestContextImp(request, response);
ctx.initialize(request);
ctx.setRequest(request);
ctx.setResponse(response);
ctx.setServletContext(getServletContext());
WebCommandFactory.getApplicationControllerCommand(ctx.getCommandName()).handleRequest(ctx);
} catch (Exception ex) {
ex.printStackTrace();
}
}

public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
processRequest(request , response);
try {
RequestContext ctx = new RequestContextImp();
ctx.initialize(request);
ctx.setRequest(request);
ctx.setResponse(response);
ctx.setServletContext(getServletContext());
WebCommandFactory.getApplicationControllerCommand(ctx.getCommandName()).handleRequest(ctx);
} catch (Exception ex) {
ex.printStackTrace();
}
}
private void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding("UTF-8");
}
for navigate to specific jsp  do like down:
static class DispatcherViewImpl implements DispatcherView {
public void dispatch(HttpServletRequest request, HttpServletResponse response, final String page, ServletContext ctx)
throws javax.servlet.ServletException, java.io.IOException {
try {
RequestDispatcher dispatcher = ctx.getRequestDispatcher(page);
dispatcher.forward(request, response);
} catch (Exception ex) {
ex.printStackTrace();
}
}
}

 
Answer #3    Answered By: Faith Hughes     Answered On: Jul 05

Thanks U for your help,and favour, but these are all the things that I've done before.
I've also tried thr filtering and j_security_check for my login form.
I believe that this might be a problem of my web  server, or sth else(I really do not know!).
But at least you're the one who helped a lot.
Thanks you more and more, and waiting to hear -READ I BELIEVE!- from U more and soon.

 
Didn't find what you were looking for? Find more on Servlet Definition Or get search suggestion and latest updates.




Tagged: