473,406 Members | 2,705 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Check url existence without opening browser, in java

Hi,

I want to check the existence of a url and i tried with the following code in java,

Expand|Select|Wrap|Line Numbers
  1.  public boolean exists(String URLName) {
  2.     try {
  3.          if (!URLName.toUpperCase().contains("HTTP")) 
  4.              URLName="http://"+URLName;
  5.              URL url = new URL(URLName);
  6.              System.setProperty("java.net.useSystemProxies", "true");
  7.              HttpURLConnection urlConn = (HttpURLConnection)  url.openConnection();
  8.                  urlConn.setConnectTimeout(9000);
  9.          urlConn.setReadTimeout(9000);            
  10.           urlConn.connect();                    
  11.                          if(HttpURLConnection.HTTP_OK == urlConn.getResponseCode())
  12.              return true;
  13. else
  14.              return false;
  15.   }
  16.  catch (SocketTimeoutException e){
  17.         return false;
  18.    }
  19.  
  20.  catch (Exception e) {
  21.        e.printStackTrace();
  22.        return false;
  23.    }
  24. }
  25.  
The above code is working fine in windows but when the code is run through server (linux) i am getting the following error message,

GConf Error: Failed to contact configuration server; some possible
causes are that you need to enable TCP/IP networking for ORBit, or
you have stale NFS locks due to a system crash. See
http://projects.gnome.org/gconf/ for information. (Details - 1:
Not running within active session)
GConf Error: Failed to contact configuration server; some possible
causes are that you need to enable TCP/IP networking for ORBit, or
you have stale NFS locks due to a system crash. See
http://projects.gnome.org/gconf/ for information. (Details - 1:
Not running within active session)
java.net.UnknownHostException: www.ep.gov
at
java.net.PlainSocketImpl.connect(PlainSocketImpl.j ava:177)
at
java.net.SocksSocketImpl.connect(SocksSocketImpl.j ava:366)
at java.net.Socket.connect(Socket.java:525)
at sun.net.NetworkClient.doConnect(NetworkClient.java :158)
at
sun.net.http://www.http.HttpClient.openServe...lient.java:394)
at
sun.net.http://www.http.HttpClient.openServe...lient.java:529)
at sun.net.www.http.HttpClient.<init>(HttpClient.java :233)
at sun.net.www.http.HttpClient.New(HttpClient.java:306)
at sun.net.www.http.HttpClient.New(HttpClient.java:323)
at
sun.net.http://www.protocol.http.HttpURLConn...ction.java:860)
at
sun.net.http://www.protocol.http.HttpURLConn...ction.java:801)
at
sun.net.http://www.protocol.http.HttpURLConn...ction.java:726)


This is a very serious issue as our project is deployed and run in server.
Jun 15 '11 #1
2 4424
Hi,

how can i check url existence in a non GUI mode.
Jun 16 '11 #2
Dheeraj Joshi
1,123 Expert 1GB
The code looks fine. So there should not be any difference between windows and linux.

May be port 80 is blocked by your firewall.

Regards
Dheeraj Joshi
Jun 17 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Matt | last post by:
I want to submit the form to the server without opening another page. When we do the following, it will submit the form data in myform to the IIS, and open page2.asp. <form name="myform"...
2
by: Ken Fine | last post by:
Using ASP, is there an easy way in code to "visit a URL", without opening a browser session? Explanation: I have a page caching class. The page caching class's behavior can effectively be...
2
by: Piyush | last post by:
Hi, I need to print stuff on the default printer on the click of a button without opening the print box opening up. Any pointers?
4
by: Jelmer | last post by:
Hi I've been trying to create an addin similar to Find & Replace from Rick Fisher that looks thru your tables / queries / forms / modules etc.. for a reference to a string and optionally let's you...
1
by: saxone | last post by:
hi all, I have created a web app in which I want to hit url's without opening a browser window. I have tried to use the following objects: ie = New SHDocVw.InternetExplorerClass wb = CType(ie,...
1
by: gajewski.konrad | last post by:
Hi All. I'm newbee. I try to check syntax any XML file. I don't have any dtd or shema file to this xml. Is this possible that I check syntax in any xml file in python. Regards, Dreamen
1
by: sandy21380 | last post by:
Hello, Is there a way of opening an Access form without opening the Access window? Right now when I open the form, the Access window is a lot bigger than the form so I have to resize the Access...
3
by: Suresh P | last post by:
Hi All, I tried to access the mysql database in ODBC using ip address and username/password. It returns, "cannot connect to MySQL server on IP ADDRESS(10060)". This could be related to Firewall...
2
by: rlu | last post by:
Is there a way to print a pdf document without opening it, if user just select the pdf files in the checkbox and click a button? I tried the following two methods, but both fail. 1. open a new...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.