0

Hey

How do I make Apache Tomcat allow to interpret PHP as well?

Allowing something like:

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException 
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<html><head><meta http-equiv='pragma' content='no-cache' /><title>Hello</title></head><body>");
out.println("<?php echo 'Hello'; ?>");
out.println("</body></html>");
out.flush();
out.close();
}

Thanks!

2
Contributors
6
Replies
7
Views
5 Years
Discussion Span
Last Post by riahc3
0

You need to have Tomcat to run on top of Apache 2 for start. However obvious question coming to my mind, what are you trying to do with this old fashion page building process????

0

My (idea) is

Login (HTML)
PHP validates it querying a BD and returns view products
Select a product and using data from the login and product selected, passes to my Java servlet to produce a file....


Basically thats the line more or less. Dont take that word for word though...

0

OK, I will call you crazy. There is no reason to do such stuff when Java is able to handle all this. Simple example can be found here in JSP section or if you willing to learn there is number of frameworks that can help you with database management like Hibernate, with website like Wicket

PS: Post is moved to JSP section

0

OK, I will call you crazy. There is no reason to do such stuff when Java is able to handle all this. Simple example can be found here in JSP section or if you willing to learn there is number of frameworks that can help you with database management like Hibernate, with website like Wicket

PS: Post is moved to JSP section

Go ahead, call me crazy :P

No, but seriously, Im doing this in PHP as I see making a servlet for this is a overkill and simply using a PHP script I can do it alot faster and easier.

0

Well then once you logged in on PHP side and have all data you may want to create request POST (attach all data you need to this request) on which servlet is specifically listening. Servlet will then retrieve data from request and do what ever it has to do. However that mean keeping bot technologies separated and communicate through request unlike you above attempt. Above is just theory, I did very little with PHP at university long time ago so I wouldn't be able to advice.

0

Ive been told today that I cant run a AMP server (to interprete PHP for example) and Java servlet on the same location.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.