*
The moose likes JSP and the fly likes JSP Includes issues Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "JSP Includes issues" Watch "JSP Includes issues" New topic
Author

JSP Includes issues

Michael Cropper
Ranch Hand

Joined: Sep 30, 2009
Posts: 137
I am having a little trouble when deploying my web app to a shared server.

The includes files I have within most of my JSPs simply won't work. Here is an example includes file



The error I am getting when running this is...


org.apache.jasper.JasperException: File "/includes/headincludes.jsp" not found
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:460)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:355)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
root cause

javax.servlet.ServletException: File "/includes/headincludes.jsp" not found
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:308)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:965)
org.apache.jsp.dashboard_jsp._jspService(dashboard_jsp.java:51)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)


Looking around on Google there doesn't seem to be many useful answers available for this issue. Except that this may be caused by the AppBase / DocBase settings in Tomcat. The problem there is that when using a shared server I don't have access to the Tomcat settings to alter this.

I have tried adding the attribute -- flush="true" -- to the jsp:include tag, and whilst that begins to generate the HTML, it stops at the first includes statement.

Has anyone come across this issue before and a way to possibly fix this?

Thanks
Michael
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61104
    
  66

Is the includes folder in the context root of the app?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Michael Cropper
Ranch Hand

Joined: Sep 30, 2009
Posts: 137
Yes I believe so. (how would I check though?)

The setup is as follows...

/
/includes/headincludes.jsp
/secure/dashboard.jsp

Within my web.xml file, I do not have anything listed for "context-root" - should I?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61104
    
  66

Michael Cropper wrote:(how would I check though?)

Is it in the same folder as WEB-INF?
Michael Cropper
Ranch Hand

Joined: Sep 30, 2009
Posts: 137
It is not in the WEB-INF folder, but it is in the same folder that WEB-INF is in.

/
/includes/headincludes.jsp
/secure/dashboard.jsp
/WEB-INF
/WEB-INF/classes
/WEB-INF/classes/packagename
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61104
    
  66

Then it looks like it's set up correctly and should work. Must be something weird about the hosting setup perhaps?

What happens if you request it directly?
Michael Cropper
Ranch Hand

Joined: Sep 30, 2009
Posts: 137
Edit: When I request the file directly it works fine. I believe it to be an issue with the virtual directories shared hosting plans set up, so that "/" isn't actually www.website.com root, but the root of the server hosting various customers websites. Although my knowledge in that area is very limited.

I will contact my web host regarding this issue then to see if they need to change any settings.

Just to check I have actually deployed the web app correctly (first time I have tried deploying it).....
I just copied everything from the "build" folder generated by Netbeans (which is all of the jsp files, class files etc all in their correct directories) into the root of my webhosting. Is that all that I needed to do?

Thanks
Michael
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61104
    
  66

I don't use Netbeans so I have no idea what it sets up.
Michael Cropper
Ranch Hand

Joined: Sep 30, 2009
Posts: 137
Netbeans simply separates all source files from the files that get uploaded to the server.

So everything that has been uploaded is just the JSP files, all WEB-INF class / library files.

By the sounds of things I have uploaded everything correctly. Just wanted to check I haven't missed something blindingly obvious such as a line of code in web.xml in relation to JSP's / includes or anything - but it it doesn't sound like it.

I will see what my web host has to say about it.

Thanks for help.

Michael
Michael Cropper
Ranch Hand

Joined: Sep 30, 2009
Posts: 137
Got this sorted with web host.

What was interesting was that www.website.com/dashboard.jsp worked, whilst www.website.com/secure/dashboard.jsp caused the errors listed above.

The solution to this was to copy the 'includes' folder into the 'secure' folder and then it worked. Whether this is actually a good solution, I am not sure, but it solved the problem.

Just in case you were interested

Thanks
Michael
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

But if I'm not mistaken, the way you say that things are working would be the way that things would work if you had this code:
Michael Cropper
Ranch Hand

Joined: Sep 30, 2009
Posts: 137
Correct.

I'm just having another play with the Servlets which have been mapped to specific URLs and something still quite doesn't seem right here, since none of them are working. Now this may just be a lag between the server refreshing the changes made in web.xml - or it could mean that the apparent fix hasn't actually fixed anything at all.

I will check on this again tomorrow.

Edit: Looking at the basic error logs I can see, this doesn't seem to be solved at all, since the "/" (root) is actually referring to the ROOT of my folders on the server, and not of the actual web app.

eg,
/home/my-user-name/public_html/secure/dashboard.html
Which is showing a "file not found" error.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSP Includes issues