Click to See Complete Forum and Search --> : Apache: PrintWriter object


pepper
06-24-2005, 04:55 PM
I am writing a web app. In my implementation I am using apache Struts and Apache Velocity (http://jakarta.apache.org/velocity/). I can't seem to get one page to display. And that is because I can't get the context of the webpage to be printed to the web page. So here is my question:

Where do I place the PrintWriter object to output the context of the webpage?

Right now I have it in my Action class (The actrion class handles the movement from page to page). I am pretty sure I am wrong in the placement but I am not sure about it. I am thinking that it needs to go in a servlet but I don't have a true servlet defined anywhere. I have Action classes and form classes. The form classes are used to hold vaules tthat were set in the forms. In my Action Classes I overwrite the execute method of "org.apache.struts.action.Action"

If anyone know's let me know

-Pepper

fatTrav
07-03-2005, 12:46 PM
I'm pretty Struts and Java webapp savvy, but I've never used Velocity. I don't quite understand what you are asking. What is it that you are trying to do exactly? Do you get any errors in the logs? What actually gets displayed when you go to that page?

Maybe you have to make sure you're not writing anything out to the response before you make the PrintWriter/context calls.

...and if you're using Struts MVC I can guarantee you have one servlet, the Struts ActionServlet...;)

pepper
07-03-2005, 03:09 PM
I figured out what my problem was. I was trying to render a page using outdated Velocity programming. All I had to do was add a variable to the request and that took care of my problem.

I have one weird problem now. I can't seem to use my web app on the tomcat that is located on my Linux machine. On my linux machine I am running 5.0.27-9 and on my windows machine I am running 5.5.7. My web app works fine on the tomcat that I am running on windows. I even downloaded the latest tomcat on my windows box to see if it was a dependency on netbeans. It wasn't, the web app worked fine. I don't know whats wrong.

My web app runs J2EE servlet engine (2.4 spec).

Any ideas why it would work on tomcat 5.5 and not 5.0?

-Pepper

fatTrav
07-04-2005, 02:31 PM
IIRC Tomcat comes with its own Servlet-API implementation, which I would assume all webapps Tomcat serves would have to use. Maybe your app, J2EE API or something requires a newer version of the Servlet-API. You might want to check both Tomcats and see which Servlet-API version they are using. Also maybe see what the difference between Tomcat 5.0.x and 5.5 is.

What do the logs say? They might infact tell you if there is a versioning problem.