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!

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????

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...

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

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.

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.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.