• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Relative call to a servlet.

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Jack Naby
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic