Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

cannot be resolved error - returning URL

 
joseph cooper
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to return an URL created from a string. I am getting an error on the return statement "site cannot be resolved". I am assuming that site is not being reconized as an URL? I am not seeing how to resolve this. Any help would be appreciated.


URL createURL(String urlString)
throws MalformedURLException
{
final String openNewInternetWindow = " target=_blank";
try
{
urlString = "http://www.google.com/";
urlString = urlString + openNewInternetWindow;
URL site = new URL(urlString);
}
catch(MalformedURLException me)
{
throw new MalformedURLException(me.getMessage());
}
return site;
} //createURL
 
Amit M Tank
Ranch Hand
Posts: 257
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
URL createURL(String urlString)
throws MalformedURLException
{
final String openNewInternetWindow = " target=_blank";
URL site = null;
try
{
urlString = "http://www.google.com/";
urlString = urlString + openNewInternetWindow;
site = new URL(urlString);
}
catch(MalformedURLException me)
{
throw new MalformedURLException(me.getMessage());
}
return site;
} //createURL
 
Rob Spoor
Sheriff
Pie
Posts: 20531
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Of course this will not work; the " target=_blank" string is NOT part of the URL - it should be another attribute to the A link element.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic