Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

JSP Includes issues

 
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Marshal
Posts: 67418
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is the includes folder in the context root of the app?
 
Michael Cropper
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Posts: 67418
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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


Is it in the same folder as WEB-INF?
 
Michael Cropper
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Posts: 67418
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Posts: 67418
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't use Netbeans so I have no idea what it sets up.
 
Michael Cropper
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Marshal
Posts: 25674
69
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
These are the worst of times and these are the best of times. And this is the best tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic