• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HFSJ example page 408

 
Catherine van Borselaer
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm trying the build the code on HFSJ page 408. This is about including a page with the <jsp:include> tag that has a body. The page i'm trying to include has the same name as in the book, "Header.jspf". In this "Header.jspf" file I try to read out this param from the body of the JSP that does this include, with EL. But it is only printing the EL statement as plain text.

When I change the file "Header.jspf" into "Header.jsp" it is working. What does make sense because it is not a .jsp file. But what about this .jspf, what is this "jsp fragment"? Is this an error in the book? I just looked in the errata page of HFSJ but there is nothing about this.

Thanks!
 
Catherine van Borselaer
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, I see, maybe it's time to rest for me. I didn't put the extra mapping in my web.xml.

<servlet-mapping>
<servlet-name>jsp</servlet-name>
<url-pattern>*.jspf</url-pattern>
</servlet-mapping>

Thanks.
 
Karthik Rajendiran
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Catherine,
Can you please explain your answer.You have given the url pattern
can u post <servlet> tag too in web.xml
 
Jamed
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you paste your whole web.xml file
 
Catherine van Borselaer
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

The problem was that with Tomcat .jspf files are not supported default. So to let these .jspf files work you must put this code in your web.xml. See the errate page of HFSJ.

My web.xml looks like this:
 
Jamed
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I only need to have jsp's and web.xml for this example.

I don't need a servlet do I ?

thanks
 
Catherine van Borselaer
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is true.
I put my whole web.xml in the reply, but then, I'm lazy...

Here's the source I used.
The includeindex.jsp



And the including page (include.jspf):



You can run it with just calling the includeindex.jsp Only make sure that this <servlet-mapping> is in your web.xml and it will work.

Good luck!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic