wood burning stoves 2.0*
The moose likes Servlets and the fly likes Relative call to a servlet. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Relative call to a servlet." Watch "Relative call to a servlet." New topic
Author

Relative call to a servlet.

Jack Naby
Greenhorn

Joined: Mar 23, 2005
Posts: 2
I need to call a servlet in my php script.

-----------------------

$tmpFileLines = file("http://www.mysite.com/servlet/servletName");

This line works but is inconvenient (major delays, bandwith issues). How do I rewrite it to use a relative call?

-----------------------

None of these work:
$tmpFileLines = file("servlet/servletName");
$tmpFileLines = file("/servlet/servletName");
$tmpFileLines = file("../servlet/servletName");

-----------------------

I have tried PHP forums but noone is able to help.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

You would call a servlet the same way you would call any other web resource.
With an HTTP Get or HTTP Post request.

You're probably even less likely to find any good help here since the code you would need to write will be in PHP.

This Google search looks promising though:
http://www.google.com/search?hl=en&q=post+requests+from+PHP&btnG=Google+Search


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Jack Naby
Greenhorn

Joined: Mar 23, 2005
Posts: 2
Using http works but it's so slow on my current hosting service that it times out. Tried to resolve this with the provider but no success. Also, every http call adds up to your bandwith which can be costly.

PHP folks are not able to help. If anyone responds, they try to blame the servlet and it's just a big waste of time. I posted here hoping someone came across a problem like that. After all, many applications interface with servlets. This isn't just a PHP question. You'd have the same problem if you were coding in ASP. Every script that needs to read a servlet and does not understand what '/servlet/' is, will face the same issue.
[ March 23, 2005: Message edited by: Jack Naby ]
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Servlets are designed to handle HTTP requests.
This is how I would access them from another app, even one written in java.

Webservices (like Apache Axis) are implemented as servlets and move along just fine.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Relative call to a servlet.
 
Similar Threads
Calling PHP from Servlet
9-1-1 emergency call. Please Help!!!!!!!!
Problem getting Servlets to work correctly with Tomcat
Compilation Error
getter and setters