Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

servlet mapping problem

 
Xiao Ava
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic