File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes servlet mapping problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "servlet mapping problem" Watch "servlet mapping problem" New topic

servlet mapping problem

Xiao Ava

Joined: Mar 26, 2004
Posts: 5
sorry to trouble but i am really struck with my assignment.

i create a jsp page called Main.jsp to upload attachment to my website
however i cannot map Main.jsp page to my servlet page with web.xml and i cannot figure where is the fault.

Map Main.jsp to servlet called

there is what i do in my web.xml

Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15300

Well, for starters you don't map a JSP page in the url-pattern. Also, the servlet-class only exists in the <servlet> definition, not in the <servlet-mapping>. Third, your UploadFile is not specified as being in a package (com.bla.UploadFile). Forth, you have specified your servlet-class as Main in the <servlet> tag when it should be UploadFile. And Fifth, the way you map your <servlet> tag to your <servlet-mapping> tag is by the <servlet-name> and have have specified 2 different names. Your web.xml should look closer to something like this below.

Keep in mind that your <url-patter> can be pretty much anything you want, so long as you map it correctly in your <form> element of your JSP page or call it correctly from another servlet.

And then in Main.jsp's <form> element, you would have something like

<form action="Upload" method="POST">
[ July 23, 2004: Message edited by: Gregg Bolinger ]

GenRocket - Experts at Building Test Data
I agree. Here's the link:
subject: servlet mapping problem