File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Open url from Servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Open url from Servlet" Watch "Open url from Servlet" New topic
Author

Open url from Servlet

yesukannan jeyaraj
Greenhorn

Joined: Nov 20, 2008
Posts: 6
hi all,
i have to open google.com from my servlet. The servlet will be called through PLSQL API so it will not will be called through browser.So i dont need javascript. Based on the operating system i openning the window. the code runs but the Google window is not oppened.

this my code

[ November 20, 2008: Message edited by: yesukannan jeyaraj ]

[BPSouther: Added code tags]

[ November 20, 2008: Message edited by: Ben Souther ]
[ November 20, 2008: Message edited by: yesukannan jeyaraj ]
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Servlets are a server side technology.
If one were to open a window, it would be on the web server machine; not the client.
Is this what you want?


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

Joined: Nov 20, 2008
Posts: 6
hi Ben,
thanks for your speedy reply.No i want it to open in the client machine. is it possible.

regards
yesukannan
[ November 20, 2008: Message edited by: yesukannan jeyaraj ]
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Servlets have no ability to 'do' anything on the client machine.
All they can do is respond to requests over the HTTP protocol.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60059
    
  65

Originally posted by yesukannan jeyaraj:
The servlet will be called through PLSQL API so it will not will be called through browser.
Sounds like you don't need it to be a servlet at all.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
yesukannan jeyaraj
Greenhorn

Joined: Nov 20, 2008
Posts: 6
hi Ben,
i am using linux OS when i run my code i get "java.io.IOException: cmd.exe: not found" error. Could you please correct me where i am moving wrong.

regards
yesukannan
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Cmd.exe is a Windows executable.
You don't need it when calling out to the Linux shell.

In any case, as Bear mentioned, this doesn't sound like a servlet issue.
yesukannan jeyaraj
Greenhorn

Joined: Nov 20, 2008
Posts: 6
hi Ben,
i am using linux OS. when i use this code in my class

String[] cmd = new String[] { "cmd.exe", "/C", "start", "http://www.google.com/search?q=Java+Tutorial" };
Runtime.getRuntime().exec(cmd);

instead of Runtime.getRuntime().exec(new String[] {browser, url});

i get "java.io.IOException: cmd.exe: not found" error. Could you please correct me where i am going wrong.

regards
yesukannan[/QB]
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4637
    
    5

As Ben, Bear and probably others have said, you have a problem, but its not a servlet related question. You are posting in the wrong section of the Ranch.

Your specific problem appears to be that you don't realize that Linux does not have a "cmd.exe" and that is not how one does what you want in a Linux world.
Srikanth Nutigattu
Ranch Hand

Joined: Oct 30, 2007
Posts: 114
To clear this a bit, let me highlight you few points.

1. Servlets are Serverside technologies.. You CANNOT execute anything on the client using servlets.

2. If you want to open a browser on client or what ever, you need client side applications using J2SE.

3. There is NO cmd.exe in LINUX.

Please read the above posts of Ben and Bear. I think you need to seriously rethink your strategy.
[ November 21, 2008: Message edited by: Srikanth Nutigattu ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Open url from Servlet
 
Similar Threads
Jbutton to website
open Browser iexplore
Opening a browser from a java application
Session problem while trying to login automatically into app using httpunit API
Anybody know how to do this...