File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes HFSJ P408 jsp Include tag example Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "HFSJ P408 jsp Include tag example" Watch "HFSJ P408 jsp Include tag example" New topic
Author

HFSJ P408 jsp Include tag example

vitesse wei
Ranch Hand

Joined: Sep 07, 2007
Posts: 100
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


SCJP 5.0<br />SCWCD1.4<br />SCBCD5
S Vilish
Ranch Hand

Joined: Feb 06, 2007
Posts: 39
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

Joined: Feb 06, 2007
Posts: 39
i am using this web.xml

vitesse wei
Ranch Hand

Joined: Sep 07, 2007
Posts: 100
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.
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

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.


A good workman is known by his tools.
vitesse wei
Ranch Hand

Joined: Sep 07, 2007
Posts: 100
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

Joined: Feb 06, 2007
Posts: 39
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
Sheriff

Joined: Feb 05, 2003
Posts: 4727

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

Joined: Sep 07, 2007
Posts: 100
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

Joined: Feb 06, 2007
Posts: 39
check the log file in the logs folder
vitesse wei
Ranch Hand

Joined: Sep 07, 2007
Posts: 100
Thanks,Marc and Vilish,problem solved,the cause is header file in directory is Header.jspf,but I refer it as "header.jspf".
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: HFSJ P408 jsp Include tag example
 
Similar Threads
Problem with jspInit() overriding
implicit object config
Configuring JSP init parameters
Transforming web.xml
jspf not working with <jsp:include> and <jsp:param>