Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

calling servlet from java in different paths

 
preethi Ayyappan
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

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65223
95
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
Pie
Posts: 65223
95
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
Pie
Posts: 65223
95
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?
 
Bauke Scholtz
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