Solved

url.getContent() question

Posted on 2003-10-22
15
249 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
Comment Utility
So what *do* you get?
0
 

Author Comment

by:b3cf
Comment Utility
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
Comment Utility
Can you reach that in your browser?
0
 

Author Comment

by:b3cf
Comment Utility
Sure.
0
 

Author Comment

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

Expert Comment

by:CEHJ
Comment Utility
What's the ultimate objective of this code?
0
 

Author Comment

by:b3cf
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 86

Accepted Solution

by:
CEHJ earned 50 total points
Comment Utility
Why not use the precompiler 'jspc'?

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

Author Comment

by:b3cf
Comment Utility
This way its easier to maintain the code.

thanx
0
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
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
Comment Utility
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
Comment Utility
Do you know how I could use javac ?

thanx
0
 

Author Comment

by:b3cf
Comment Utility
Opps. I meant jspc.
0
 
LVL 86

Expert Comment

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

Expert Comment

by:CEHJ
Comment Utility
:-)
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

728 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now