• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to set url while creating URL class object  RSS feed

 
Kaustubh Bholee
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am having one Eclipse Dynamic Web project. On running, its login page url looks like "localhost:8080/PTSCR_Project/login/homeLogin.action".

Now I am creating one URL class object in another project like



But it is showing NULL POINTER EXCEPTION.

Also if I am having html file "a.html" in say E: drive of my pc, can I write something like



Please help me on it asap.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An URL starts with the protocol, something like "http://".
 
Kaustubh Bholee
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried with http too as



But again Null Pointer Exception...
 
James Boswell
Bartender
Posts: 1051
5
Chrome Eclipse IDE Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you post your entire code and the full stack trace please?
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Incorrect URLs won't throw a NullPointerException but a MalformedURLException. Are you sure that's the line that's causing the problem?

As for using URLs to the local file system, use new File(...).toURI().toURL().

Kaustubh Bholee wrote:Please help me on it asap.

Please EaseUp.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!