• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

calling servlet from java in different paths  RSS feed

 
Ranch Hand
Posts: 518
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I am having a java program (sample1.java)in the path /var/lib/asterisk/agi-bin. my servlet program(sample2.java) is in another path /usr/local/apache-tomcat/webapps/voicebroadcast/WEB-INF/classes.

Is it possible to call servlet from java like

sample2 s2=new sample2();
s2.doGet(request, response);

Thanks in advance

 
Author and ninkuma
Marshal
Posts: 66806
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where will you get the request and response implementations from?
 
preethi Ayyappan
Ranch Hand
Posts: 518
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry.I dont need to get the request and response.but can i get just a string variable like

sample2 s2=new sample2();
String var= s2.campaign;
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66806
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then how would you plan to call doGet() without a request and response?
 
preethi Ayyappan
Ranch Hand
Posts: 518
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes.I didn't think about that.so, is it impossible to call the servlet from java? or any other way?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66806
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not without implementing a servlet container yourself, which I assume is not your intention.

What is it that you are really trying to accomplish?
 
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you need some business logic provided by the other servlet, then that servlet code is likely subject to refactoring. Separate the tight coupled code into separate class(es) so that you could reuse it in another (servlet) classes.

If you actually need to access the servlet by HTTP request and you need its HTTP response programmatically, then take a look for java.net.URLConnection or, a bit more enhanced, the Apache Commons HttpClient API.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!