Solved

url.getContent() question

Posted on 2003-10-22
15
255 Views
Last Modified: 2013-11-24
Hi
  I am trying to use url.getContent(). But the it does not reach
 System.out.println("here  333");
  I am running this in a servlet. Could anybody help me solve this.

Thanx


java.net.URL url = null;
    try {
       System.out.println("here  111");
      url = new java.net.URL("http://www.news.com/");
         System.out.println("here  222");
      Object foo = url.getContent();
         System.out.println("here  333");
    }
    catch (java.net.MalformedURLException ex) {
     System.err.println("Exception thrown - SetupServlet 1" + ex.getMessage());
    }
     catch (IOException e) {
                              System.err.println("Exception thrown - SetupServlet 1" + e.getMessage());
                        }
0
Comment
Question by:b3cf
  • 8
  • 7
15 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 9601071
So what *do* you get?
0
 

Author Comment

by:b3cf
ID: 9601141
It threw an unreachable exception.

I am trying the following, but no response for the last few minutes.
java.net.URL("http://localhost:8080/ChartsV2.0/jsp/index.jsp");

thanx
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 9601160
Can you reach that in your browser?
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

Author Comment

by:b3cf
ID: 9601164
Sure.
0
 

Author Comment

by:b3cf
ID: 9601188
Not if I run thed code in my servlet though.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 9601252
What's the ultimate objective of this code?
0
 

Author Comment

by:b3cf
ID: 9601284
To precompile JSP pages when Tomcat starts.

I know Tomcat has to be started for this code to work.

If i have this code the following messages from Tomcat wont be displayed.

Oct 22, 2003 3:58:35 PM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on port 8080
Oct 22, 2003 3:58:35 PM org.apache.jk.common.ChannelSocket init
INFO: JK2: ajp13 listening on /0.0.0.0:8009
Oct 22, 2003 3:58:35 PM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/90  config=d:\jakarta-tomcat-4.1.27\conf\jk2.proper
ties
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 50 total points
ID: 9601339
Why not use the precompiler 'jspc'?

http://ant.apache.org/manual/OptionalTasks/jspc.html
0
 

Author Comment

by:b3cf
ID: 9601386
This way its easier to maintain the code.

thanx
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 9601400
How could that be? Every time you add a new page you have to make a change to the servlet's source code and recompile it.
0
 

Author Comment

by:b3cf
ID: 9601444
No. I just get all the files under jsp that has .jsp extension and do it. I have hardcoded just for testing.

thanx
0
 

Author Comment

by:b3cf
ID: 9601595
Do you know how I could use javac ?

thanx
0
 

Author Comment

by:b3cf
ID: 9601625
Opps. I meant jspc.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 9601911
See the link i posted above. This is a serious way of doing things.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 9651632
:-)
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
V.simple question about Android packages and libraries 1 19
simple java question 3 55
servlet doXXX methods 3 49
What's wrong with this code? 4 22
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question