Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » creating URL in java
creating URL in java [message #1216211] Thu, 28 November 2013 11:17
suvarna deo is currently offline suvarna deoFriend
Messages: 11
Registered: August 2013
Junior Member
Hii to all

m linux user... Developing my project in Eclipse IDE. and the project structure folder

is Merchant.com(my project name)-->WebContent-->pg(folder)-->index.html(file). I m run

this project on tomcat server so that the folder structure is

mycomputer-->usr-->shear-->Apachetomcat-->webapps-->MyProject(created manually by

me)-->Merchant.com

my code is

public class Url {
 
	/**
	 * @param args
	 */
	
		public static void main(String[] args) {
	        try {
	            //
	            // Creating a url object by specifing each parameter separately, including
	            // the protocol, hostname, port number, and the page name
	            //
	            URL url = new URL("http", "www.Merchant.com" , 80, "/pg/index.html");
	            
	            //URL url = new URL("http://Merchant.com/pg/index.html");
	            // We can also specify the address in a single line.
	           
	           
	            BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));
	 
	            String line;
	            while ((line = reader.readLine()) != null) {
	                System.out.println(line);
	            }
	 
	            reader.close();
	        } catch (MalformedURLException e) {
	            e.printStackTrace();
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
 
	}
 
}
 


I m getting 404 error when i run this as a java application.
so my question is where do i put index.html? AM i missing something?

[Updated on: Thu, 28 November 2013 13:29]

Report message to a moderator

Previous Topic:Problems with DirectoryDialog
Next Topic:Using tomcat in eclipse with apache/mod_jk
Goto Forum:
  


Current Time: Wed Sep 25 21:45:27 GMT 2024

Powered by FUDForum. Page generated in 0.03362 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top