aspose file tools*
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


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "servlet mapping problem" Watch "servlet mapping problem" New topic
Author

servlet mapping problem

Xiao Ava
Greenhorn

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 UploadFile.java

there is what i do in my web.xml

<web-app>
<servlet>
<servlet-name>Main</servlet-name>
<servlet-class>Main</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>UploadFile</servlet-name>
<servlet-class>UploadFile</servlet-class>
<url-pattern>/Main.jsp</url-pattern>
</servlet-mapping>
</web-app>
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

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">
..
</form>
[ July 23, 2004: Message edited by: Gregg Bolinger ]

GenRocket - Experts at Building Test Data
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: servlet mapping problem