Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need help in deploying Counter example in chapter 7

 
Ken Teoh
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,

I have some trouble deploying the Counter example in chapter 7.
I'm not too sure how the web.xml file is like.
I'm getting an error

The requested resource (/testJSP1/BasicCounter.jsp) is not available.


Here are the details of my web.xml file

<web-app xmnls="http://java.sun.com/xml/ns/j2ee" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
<servlet>
<servlet-name>BasicCounter</servlet-name>
<jsp-file>/BasicCounter.jsp</jsp-file>
<servlet-class>Counter</servlet-class>
</servlet>
</web-app>



Thanks for helping
 
Dilshan Edirisuriya
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you declare the <servlet-mapping> in DD?
 
Senthil Kumar
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Both <jsp-file> and <servlet-class> tags should not appear together.Remove the <servlet-class> tag and specify the mapping for the jsp's servlet and then access it via url pattern.
 
Ken Teoh
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Senthil

Was your DD like this?
<web-app xmnls="http://java.sun.com/xml/ns/j2ee" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">

<servlet>
<servlet-name>Counter</servlet-name>
<jsp-file>/BasicCounter.jsp</jsp-file>
</servlet>

<servlet-mapping>
<servlet-name>Counter</servlet-name>
<url-pattern>/BasicCounter.jsp</url-pattern>
</servlet-mapping>

</web-app>

I did what you suggested but I get a

org.apache.jasper.JasperException: Unable to compile class for JSP

Thanks
 
Dilshan Edirisuriya
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Ken your DD is incorrect.
Put <?xml version="1.0" encoding="ISO-8859-1"?> above the <web-app>
 
Ken Teoh
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Dilshan,

Thanks alot its working right now. Do you know why its required? I tried it without the line in the example in chapter 3 and it works
 
Dilshan Edirisuriya
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have no idea. It can be seen in tomcat examples. So just copied it and used it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic