This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Waiting for page loading and get title of the page

 
Marco Zanini
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi to all,
I need to get a parameter who's inside the title of a web page. I am using servlets and java. How can I do? I suppose I should wait for the page to load too.

Many thanks!
 
Prasad Krishnegowda
Ranch Hand
Posts: 667
4
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just Curious, why would you want that parameter?
 
Marco Zanini
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because of this: http://code.google.com/intl/it-IT/apis/accounts/docs/OAuth2InstalledApp.html Look under the section "Choosing a redirect URI"
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64683
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean by a "parameter in the title"?
 
Prasad Krishnegowda
Ranch Hand
Posts: 667
4
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By seeing the link, i guess, you want the authorization code, in the same link, in Handling the response section, they say, authorization code is passed as code, getting this field is not going to help you?
 
Marco Zanini
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You ask google for an authorization code and google will provide you one embedded in the title of the page. You should save it and send it again to google together with other parameters to get an access token.

Authorization code is passed as code when you send it to Google. I think that this phrase in that link leaves no doubts: "The authorization code can be returned to your application in the title bar of the browser or to an http://localhost port in the query string."
 
Paul Clapham
Sheriff
Pie
Posts: 20945
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm confused by the phrase "I need to get".

You can easily see the page title by looking at the top of the browser. But apparently you want to "get" the value in some other way?
 
Marco Zanini
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh sorry, I need to acquire it with my application without user intervention.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64683
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Be very very very precise about what you mean by the "title of the page". The only thing I can take that to mean is the text in the <title> tags, and that makes no sense whatsoever.
 
Paul Clapham
Sheriff
Pie
Posts: 20945
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Marco Zanini wrote:Oh sorry, I need to acquire it with my application without user intervention.


I'm still baffled. There's a web page somewhere (you didn't say where). And you have an application which I suppose must be running, although you didn't say where. Except that you're using servlets, which I suppose means it's a web application. And I suppose there must be some relationship between this application and the web page, but you haven't said anything about how that relationship is established.
 
Marco Zanini
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So, I have to be sorry again, many times one thinks things are well explained but it's wrong.

So I have an application running on a web server on my machine. I want to obtain access to google services using oAuth. So I have to make a request to the Google server with some parameters and read the parameter in the response which is embedded in the title of the page. This is because for authoriing the application the user is redirected to an url that asks him for permissions and then Google redirects the browser to the webpage which title I have to examine.

I hope now everything is clear, thank you for your patience.
 
Paul Clapham
Sheriff
Pie
Posts: 20945
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Marco Zanini wrote:So I have an application running on a web server on my machine. I want to obtain access to google services using oAuth. So I have to make a request to the Google server with some parameters and read the parameter in the response which is embedded in the title of the page.


So your servlet should send a request to this Google URL, and then parse the response with an HTML parser in order to extract the <title> element. Something like Apache HttpClient might help, although a plain old URLConnection might work just fine if the request is a GET request. And if the HTML returned is simple enough, you might even be able to just extract the data from the <title> element using plain old string processing.

This is because for authoriing the application the user is redirected to an url that asks him for permissions and then Google redirects the browser to the webpage which title I have to examine.


Am I correct in assuming that what you describe here is a process which you are automating? So instead of the user going to the Google URL and entering the permission information, you want your application to do that instead? If so then probably the process I described there isn't the way to do it. I found a variety of tutorials with names like "OAuth for Web Applications" which seem to me to describe what you should be doing, and scraping the response for <title> elements didn't seem to feature in those tutorials.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic