LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 11-14-2005, 11:58 PM   #1
Runnerdave
LQ Newbie
 
Registered: Jul 2005
Location: Australia
Posts: 13

Rep: Reputation: 0
JAVA how to trigger a servlet without a link or a browser request?


I need to trigger a servlet, that is to call it as you do when you click a link that maps to it, but I need a way to do it from the application without the user interaction, any ideas?
 
Old 11-15-2005, 02:10 AM   #2
zeitounator
Member
 
Registered: Aug 2003
Location: Montpellier, France, Europe, World, Solar System
Distribution: Debian Sarge, Fedora core 5 (i386 and x86_64)
Posts: 262

Rep: Reputation: 30
send an http request to the servlet from the application. Have a look at the java.net package documentation http://java.sun.com/j2se/1.5.0/docs/api
 
Old 11-15-2005, 04:14 PM   #3
Runnerdave
LQ Newbie
 
Registered: Jul 2005
Location: Australia
Posts: 13

Original Poster
Rep: Reputation: 0
thanks zeito that is what I want to do, send a http request, but HOW??
 
Old 11-16-2005, 07:14 AM   #4
zeitounator
Member
 
Registered: Aug 2003
Location: Montpellier, France, Europe, World, Solar System
Distribution: Debian Sarge, Fedora core 5 (i386 and x86_64)
Posts: 262

Rep: Reputation: 30
What is the application you want to trigger the servlet from ? Which language is it written in ?

You need to provide some more info if you want people to help you efficiently....

If your application is written in java, did your have a look at the doc link I sent above ?
 
Old 11-16-2005, 05:47 PM   #5
Runnerdave
LQ Newbie
 
Registered: Jul 2005
Location: Australia
Posts: 13

Original Poster
Rep: Reputation: 0
yes it is written in java and it is another servlet or a jsp from it should be activated but without the user having to click on a link.

I read a bit the spec you sent me and I think it has something to do with the request dispatcher but not sure how.

thanks again, and I love your signature
 
Old 11-17-2005, 02:26 AM   #6
zeitounator
Member
 
Registered: Aug 2003
Location: Montpellier, France, Europe, World, Solar System
Distribution: Debian Sarge, Fedora core 5 (i386 and x86_64)
Posts: 262

Rep: Reputation: 30
Did not program in java for quite a long time now... but having a closer look at the doc, I think what you need is to create an HttpURLConnection. Probably something like:
Code:
import java.net.*
#########
theConnection = new HttpURLConnection("http://yourserver.com/path/to/your/servlet");
try {
    /* set some http options for the object. here*/
    theConnection.connect();
    /* do some stuff with the response such as => */
    theResponseCode = theConnection.responseCode;
    thPage=theConnection.getContent();
} catch (SocketTimeoutException e) {
    /* do some stuff for socket timeout */
} catch (IOException e) {
    /* do some stuff for IO exception */
}
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Media Link Up Trigger in Linux Ethernet driver bond_7942 Linux - Software 3 06-18-2005 06:03 AM
install Java (Servlet), Tomcat on Fedora need help. learn Fedora 2 02-24-2004 11:28 PM
installing java servlet develpment kit senthilasks Linux - Software 1 08-27-2003 01:15 AM
compiling a java program on server using servlet? raghutv Programming 1 03-15-2003 06:17 AM
Java Applet/Servlet Needed bfloeagle Programming 8 08-19-2002 09:23 AM


All times are GMT -5. The time now is 07:31 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration