*
The moose likes Java in General and the fly likes cannot be resolved error - returning URL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "cannot be resolved error - returning URL" Watch "cannot be resolved error - returning URL" New topic
Author

cannot be resolved error - returning URL

joseph cooper
Ranch Hand

Joined: Nov 08, 2005
Posts: 44
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

Joined: Mar 28, 2004
Posts: 257
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


Amit Tank
Linked In
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19651
    
  18

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: cannot be resolved error - returning URL
 
Similar Threads
Reading Remote File
java.io.IOException: Server returned HTTP response code: 401 for URL:
Request web Page on Glassfish server using java code
validating URL without using exception
Passing cookies back and forth