Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners Creating URL in java

Have Programming Question? Ask it here!
 
 
 


suvarna
Creating URL in java
2 Answer(s)      9 months ago
Posted in : Java Beginners


Hii to all

I m trying to create a url using java. Address is http://www.merchant.com/pg/index.html

When i m going to run this address on browser i got error 404 page not found.

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/index.html");
                // We can also specify the address in a single line.
                //www.merchant.com/pg/index.html

                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();
            }

    }

}

How to solve this? Plz help.


Advertisement
View Answers

November 27, 2013 at 2:00 PM


Hi,

Please check the tutorial Java File Download Example.

Thanks



November 28, 2013 at 3:45 PM


I 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"

so my question is where do i put index.html? AM i missing something?



Related Tutorials/Questions & Answers:
Creating URL in java
Creating URL in java  Hii to all I m trying to create a url using java. Address is http://www.merchant.com/pg/index.html When i m going to run... Url { /** * @param args */ public static void main(String
creating a friendly url for web application
creating a friendly url for web application  Hi all, I don't know how to create a friendly url for a web application. Please help me to resolve this problem. Thanks, Suresh
Advertisements
Creating URL using <c:url>
Creating URL using <c:url>   ... by creating it or by or by using the existing one. If the browser doesn't support the cookies then the container will automatically use the URL rewriting
java referer url
java referer url  How to get the referer url in Java? Thanks
Java URL inputstream caching
Java URL inputstream caching  I have a web application in which the header is displayed by hitting a URL. Since the header content doesnt change always i wanted to cache the results of the URL inputstream and refresh it for every
URL Block - Java Beginners
URL Block  Hello sir, How to block one website using java.for example if we want block "www.orkut.com" site,how to block this site using java... to block a URL like this?please help me.. Thanking you
Creating a memory leak with Java
Creating a memory leak with Java  Creating a memory leak with Java
HTTP URL Address Encoding in Java
HTTP URL Address Encoding in Java  HTTP URL Address Encoding in Java
Creating PDF in JAVA
Creating PDF in JAVA  How create pdf in java ? Take value from database for particular PDF
creating reports in java
creating reports in java  how to create reports automatically in java and send it via mail by scheduling tine for weekly,monthly basis
creating JAR - Java Beginners
creating JAR  I am beginner in J2ee.I am creating an application... installed SQL and Tomcat.I created a JAR of my java project and included in the library of web project. My problems 1. I added new class in the java project
creating java classes
creating java classes  Create a Java class that can be used to store inventory information about a book. Your class should store the book title... a program that tests your class by creating and using at least two objects of the class
URL Rewriting in Java
URL Rewriting in Java URL rewriting a session management technique and in this tutorial, you will be informed about URL Rewriting in Java. URL writing is a way, which is used to hide the original URL. It is commonly handle by filter, You
creating packages in java
creating packages in java  Hi everybody, I am Rupesh Narayan, i faces a problem while creating package in core java. I write two programs that are described below:- 1.PackageDemo.java package javaclass; import java.io.*; public
creating Xml - Java Beginners
creating Xml  how we can create a xml file using java Creating XML File is possible in java with this packages. import... this Elemnts to DOcumnet object. Creating XML File is possible  Creating XML File is possible
creating java classes
creating java classes  This program uses a class named DrivingLicense to keep track of two driving licenses, including the driver?s name, and the number of speeding tickets they have received. You may not modify the DLTest code
How to Overcome proxy in Java URL connection
How to Overcome proxy in Java URL connection  Hi, I'm just trying to make java url connection. But it shows some errors due to proxy ..... I would like to read a URL (http://google.com) using java url, i made the url
Saving URL in local disk - Java Beginners
Saving URL in local disk  Hi Friend, How can i Save URL like "www.jagran.com " on local disk throgh java Statement. Thanks ,in advance
java coding for creating table in the console
java coding for creating table in the console  write a java program to create table
java how to get domain name from url
java how to get domain name from url  How to get the domain name from a url string? Example program in java for "how to get domain name from url" Thanks   Hi, You can use the following example code: URL linkURL
creating an .exe file - Java Beginners
creating an .exe file  how to create an .exe file in java? thanks in advance
creating browse button - Java Beginners
creating browse button  how can we create a browse button along with a textfield in java swings
creating browse button - Java Beginners
creating browse button  how can we create a browse button along with a textfield in java swings
creating browse button - Java Beginners
creating browse button  how can we create a browse button along with a textfield in java swings
creating browse button - Java Beginners
creating browse button  how can we create a browse button along with a textfield in java swings
creating browse button - Java Beginners
creating browse button  how can we create a browse button along with a textfield in java swings
creating browse button - Java Beginners
creating browse button  how can we create a browse button along with a textfield in java swings
creating browse button - Java Beginners
creating browse button  how can we create a browse button along with a textfield in java swings
creating browse button - Java Beginners
creating browse button  how can we create a browse button along with a textfield in java swings
creating browse button - Java Beginners
creating browse button  how can we create a browse button along with a textfield in java swings
creating browse button - Java Beginners
creating browse button  how can we create a browse button along with a textfield in java swings
creating browse button - Java Beginners
creating browse button  how can we create a browse button along with a textfield in java swings
Creating Excel sheets - Java Beginners
Creating Excel sheets  Hi, I want the java code for creating excels sheets with two workbooks using POI, and to find the difference between the particular value of one cell and others. asuming the contents of teh files adn
Friendly URl
Friendly URl  creating a SEO friendly URL
creating browse button - Java Beginners
creating browse button  how can we create a browse button along with a textfield in java swings.  Hi friend, import... on Java visit to : http://www.roseindia.net/java/example/java/swing/ Thanks
Creating JAR File - Java Beginners
Creating JAR File  Respected Sir, Thankyou very much for your reply, I had tried what you told me. The same error is coming back again to me, which says, Failed to load Main-Class manifest attribute from H:\Stuff\NIIT\Java
creating multiple threads - Java Beginners
creating multiple threads  demonstrate a java program using multiple thread to create stack and perform both push and pop operation synchronously.  Hi friend, Use the following code: import java.util.*; class
Java file from url
Java file from url In this section, you will learn how to convert url to file. Description of code: We have already told you the conversion of file to url... urlstring = "file:///C:/java/examples/data.txt"; URL u = new URL(urlstring
creating a modal frame - Java Beginners
creating a modal frame  i have a JFrame with 2 textfields. i want that this frame should open in a modal mode. how to do this? please tell. thanks
Creating JAR File - Java Beginners
Creating JAR File  Respected Sir, I would like you to please help me, in letting me know, as to how to create JAR file from my JAVA source or class files. And what is this manifest file, and what changes needs to be done
Java GUI code- creating a circle
Java GUI code- creating a circle  My assignment is to write a program that prompts the user to enter the center and a point on the circle, which is (x,y)(x2,y2). The program should then output the circle's radius, circumference
Overview of Networking through JAVA,How to retrieve URL information
the network information for a given URL. In the given below example we use the URL class and make a object. After creating a object we assign a new URL... How to retrieve URL information   
Overview of Networking through JAVA,Convert URI to URL
Convert URI to URL      ... Identifier (URI) reference to uniform resource locator (URL). Here we are give... in the example we make a  URI object and a URL object. After that we pass a URI "
creating class and methods - Java Beginners
creating class and methods  Create a class Computer that stores... quantity; public Computer(String n,int s,int sp,String m,double p,int q){ name=n; size=s; speed=sp; make=m; price=p; quantity=q; } public String
Creating Java Object in Vbscript - Development process
Creating Java Object in Vbscript  How to create a java object in Vbscript. Please give the detailed steps to create a java Object in Vbscript
URL in term of Java Network Programming
URL in term of Java Network Programming.... In this section we will provide the complete information about the way of using URL in java... are provide a simple name structure of a URL which addresses the Java Web site
Java file to url
Java file to url In this section, you will learn how to convert file to url... void main(String[] args) throws Exception { File file = new File("C:/Java... easily convert file to url whether there is a simple path or contains special
creating a java bean application - IDE Questions
creating a java bean application  hi, i want to create a java bean using BDK. please tell me all the steps for creating a simple java bean application. i have also a confusion about the properties of java bean. please explain
creating java linked list - Java Beginners
creating java linked list  how can one create a sorted linked list. thats adding it to the queue? thans in advance.  Hi , import java.util.*; public class QueueList { public static void main(String
Java Servlet : URL Rewriting
Java Servlet : URL Rewriting In this tutorial, we will discuss about URL Rewriting. It is one of session tracking technique. URL Rewriting : You can use another way of session tracking that is URL rewriting where your browser does
 

 

 

DMCA.com