I have a link called Print to PDF. When the user clicks this link, I call a JSP… the JSP I posted above.
This JSP is located in the directory jsp/JspName.
This JSP then calls a servlet which converts the data on the page with the link to PDF and displays the PDF document in this window.
My problem that was occurring is since I have the JSP located in a directory called JSP, posting of the form mainForm was not calling the servlet Print.
So I hardcoded the servlet context in front of the servlet print and everything worked.
Based on your suggestion of request.getServletContext(), when I try this Eclipse tells me “The method getServletContext is undefined for the type HttpServletRequest”.
Is this not an HttpServlet request? I am not sure why this is not an option for me. If you can not tell, I am still learning how to code with JSP’s.
The Servlet Context is the server container that holds your servlet, a servlet/JSP programmer rarely, if ever, needs to access this (and should have a really, really good reason for doing so)
As I hinted at above, the easiest way to troubleshoot a misbehaving JSP is to look at the page source and see what it is outputting, then look in your logs for errors.
Thank you for clarifying this but I do not think I am asking the correct questions.
In Eclipse, I named my dynamic web project testingApp. I am running the app thru Tomcat 5.5 in Eclipse. So when Eclipse builds the project, in the wtpwebapps directory, it builds a directory called testingApp. In testing app is where all of my code is for this project. So I was referring to this as the servlet context for this project.
Now, when I do my form post from my JSP, if I hard code this, everything works.
So what I am trying to do is use code to determine the value “testingApp” instead of hard coding it.
When I use the getServletPath(), it is returning the location of my jsp. How can I get the value, testingApp?
Also, this is not a strong area for my, so I am not offended at all if you correct how I refer to things. It will only increase my understanding so I do appreciate any feedback.