Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Trusted Contributor
foufou
Posts: 109
Registered: ‎11-15-2011
My Device: blackberry 9800

get absolute url on handle ressource request on blackberry

 I use this method the get the urls of ressources contain on web page

publicInputConnection handleResourceRequest(BrowserFieldRequest request)throwsException{finalString url = request.getURL();returnsuper.handleResourceRequest(request);}

 

But, I made request.getURL(); it returns relative url and not the absolute url.

How can I change it to get the absolute URL?

Please use plain text.
Developer
peter_strange
Posts: 19,608
Registered: ‎07-14-2008
My Device: Not Specified

Re: get absolute url on handle resource request on blackberry

[ Edited ]

I'm guessing this is related to your other Thread:

http://supportforums.blackberry.com/t5/Java-Development/TOO-MANY-THREADS-ERROR-EXCEPTION/td-p/209951...

In that Thread I suggest that you actually process the response from the

super.handleResourceRequest(request);

yourself.  In other words, read the InputStream yourself, save it, then provide as a return to this method, an InputConnection that you construct yourself from the data you have downloaded. 

 

This will provide you with the offline data you need.  You should save it so that you can retrieve the data using the URL that you get from the page. 

 

With respect to your actual question, my experience is that the URL returned is not relative. Can you print out an example and show us what you get to demonstrate that it is?

Please use plain text.
Trusted Contributor
foufou
Posts: 109
Registered: ‎11-15-2011
My Device: blackberry 9800

Re: get absolute url on handle resource request on blackberry

How can I read the input stream if the url get it from the request not the correct url?

Please use plain text.
Developer
peter_strange
Posts: 19,608
Registered: ‎07-14-2008
My Device: Not Specified

Re: get absolute url on handle resource request on blackberry

OK, I'm sorry I have confused the issue.  Ignore my comments for now.  Hopefully they will make sense at some stage. 

 

As noted, I have never seen getURL return a relative URL.  Can you show us an example where

final String url = request.getURL();

gives a relative URL?

Please use plain text.
Trusted Contributor
foufou
Posts: 109
Registered: ‎11-15-2011
My Device: blackberry 9800

Re: get absolute url on handle resource request on blackberry

for example I have this  in the web page

<link class="lia-link-navigation hidden live-links" title="topic Running out of threads and InvokeLater in Java Development" type="application/rss+xml" rel="alternate" id="link" href="/rim/rss/message?board.id=java_dev&amp;message.id=108366"></link>
 final String url = request.getURL();

 

 return something like this add http:/ +relative url ==>

http:/rim/rss/message?board.id=java_dev&amp;message.id=108366
Please use plain text.
Developer
peter_strange
Posts: 19,608
Registered: ‎07-14-2008
My Device: Not Specified

Re: get absolute url on handle resource request on blackberry

Please change your code to output the url that you get.  So add a

System.out.println(url);

to your method after

final String url = request.getURL();

Put a break point after that and tell us what you see in the output. 

 

Is the output a relative url or not?

 

Note that the HTML you provided would go through the navigationRequest method not the ResourceRequest - but even in there you will, in my experience, get the complete URL. 

 

So please try it in your method rather than assuming what you will get is the same as the HTML code that is being processed. 

Please use plain text.
Trusted Contributor
foufou
Posts: 109
Registered: ‎11-15-2011
My Device: blackberry 9800

Re: get absolute url on handle resource request on blackberry

I told you the url what I get in the method and I show you the src that should I get in the code HTML. It's the same thing.

Please see my answer and the url that I get. It didn't contain the domain

Please use plain text.
Developer
peter_strange
Posts: 19,608
Registered: ‎07-14-2008
My Device: Not Specified

Re: get absolute url on handle resource request on blackberry

[ Edited ]

The html source that you gave above was for a <link>.  A <link> is a navigation request NOT a resource request.  So this statement:

"I told you the url what I get in the method and I show you the src that should I get in the code HTML"

can not be correct.

 

Please put the statement in your code as I suggested.  When you have demonstrated that you really get a relative URL, then we will look further.  For the moment you have not demonstrated that. 

 

Edit: Note from below it appears this was in fact generated from a navigationRequest, and the same thing is shown in a resourceRequest.

Please use plain text.
Trusted Contributor
foufou
Posts: 109
Registered: ‎11-15-2011
My Device: blackberry 9800

Re: get absolute url on handle resource request on blackberry

<LINK rel="stylesheet" href="web/css/file1.css">
url= request.getURL();====>http:/web/css/file1.css

 

and for 

<script language="javascript" src="web/filesJs/file1.js">
url= request.getURL();====>http:/web/filesJs/file1.js

 

Please use plain text.
Developer
peter_strange
Posts: 19,608
Registered: ‎07-14-2008
My Device: Not Specified

Re: get absolute url on handle resource request on blackberry

OK, I see now, sorry for not understanding earlier.  I have never seen anything like that before.

 

Is this using a page that I can reference?

 

Can you tell me what level of OS you are testing with?  

Please use plain text.