• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

HFSJ P408 jsp Include tag example

 
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I try to test the jsp include tag exmple in page 408,but I can not get any result from included file,I can not find the problems cause this,my server is tomcat 5.
web.xml

contact1.jsp

header1.jspf

what i get from browser(contact1.jsp) is like this
------------------------------------------
We can help.

Contact us at:likewecare@wickedlysmart.com
------------------------------------------
anybody can help me fix this
 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It works. Don't see any probem in code except a meaningless servlet-mapping tag in web.xml, you can delete that.

write in the very first line in header.jspf


if you see it getting printed means jsp include is working.

I am using tomcat 5.5, try server restart
 
S Vilish
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i am using this web.xml

 
vitesse wei
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,Vilish,
I try on Tomcat6 and revised web.xml and head.jsp,it still don't bring me nothing from included file,can you post your translated Contact_jsp.java on tomcat\work\Catalina\localhost\IncludeTest\org\apache\jsp,here is mine,please compare the code in bold.
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
vitesse, I think I know the answer to your problem. The container is not able to find your file to include. I have a theory why.

I believe your header file has an extension in the filename that Windows is not displaying (or you are not noticing). Browse to your directory that contains the header file. Each file in the directory should say the file type in addition to the name. It could say "JSP File", "JSPF File", "Text Document", "Rich Text Format", or another type. If your type says "Text Document" then your file is really named something like header1.jspf.txt even though it looks like header1.jspf - which would explain why the container can't find the file.

By the way, your original posted code works great on my machine (aside from me not having a copy of that image) and I'm using Tomcat 5.

Someone said the servlet mapping is pointless but it is not pointless in Tomcat I don't think. I believe Tomcat doesn't understand the .jspf extension convention and that mapping can be added to the web.xml to make it treat jspf files like a jsp.
 
vitesse wei
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for reply,
I checked file extension,it's fine,I restarted server,reload the app from tomcat manager,delete IE temp file,restarted IE,access this app from remote,it's still not working,anybody help check the code:
Contact.jsp:

Header.jsp

web.xml

translated java code for jsp:include

translated java code for EL in header.jsp file
 
S Vilish
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
vitesse, I will look and post.

currently i am different machine with no tomcat and also busy a bit in some work.

Vilish
 
Marc Peabody
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by vitesse wei:
anybody help check the code:


The translated code is not the problem. The problem is that it can't find your header file. But since you probably won't drop insisting, here's mine to show you it's the same:
contact1.jsp

and header1.jspf:

Are your files in the same directory? There is something not correct about your setup that is preventing the container from finding the header.
 
vitesse wei
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
marc,thanks for reply,
I have two file Contact.jsp and Header.jsp(I change back to from jspf to jsp) in app root,and web.xml in WEB-INF,I checked translated code and class file,there are two java code files(Contact_jsp.java and Header_jsp.java) and two class files(Contact_jsp.class and Header_jsp.class).only two files,they are in same directory and both are translated and compiled,how could it can't find header file,I think maybe something wrong with my container setup.but no clues with this?
 
S Vilish
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
check the log file in the logs folder
 
vitesse wei
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks,Marc and Vilish,problem solved,the cause is header file in directory is Header.jspf,but I refer it as "header.jspf".
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic