Hi All,
I'm trying to get a set of servlets to work , these servlets are meant to interact with the foursquare API , and help me authorize a web application to run on their DB.
I try However, I'm getting a resource not found error. This is my web.xml
This is how I intend the flow of servlets to be - The user is authenticated in the Login servlet and then supposed go on to the auth sevlet with a code handle , however I get the error at this point.
Below is the code of the Login servlet
Hi Bear,
Thanks for the quick reply! The logs indicate that Login class (responsible for authentication)executes correctly and Im able to print the redirect url , as well
Then the page redirects and loads the required page on foursquare.com, Which asks for a confirmation whether I would like my account to be accessed , and when I do allow it to be accessed, it redirects to the correct url with an authentication code. But the browser throws a 404 error. here's my authentication class , if thats of any help
Well Bear , I think I did . In the post above ,(quoted below) and that is all Im printing.
Vic Hood wrote:Hi Bear,
Thanks for the quick reply! The logs indicate that Login class (responsible for authentication)executes correctly and Im able to print the redirect url , as well
Bear Bibeault wrote:You're sending a URL to foursquare that contains localhost as a server domain? Really? Think about that for a few second.
Uh yes. It did strange to me too, however I thought that was the way foursquare expected me to access their endpoint. In fact , Im just trying to implement the auth servlet from a code sample on this blog. Quoting from the same blog
.
Users accessing your application need to sign-in to their foursquare account. Once they are signed in, your application can access their data.
First step in authentication is to redirect your users to:
If user signs in, foursquare will send a “CODE” to the path specified in redirect_uri. For instance, if your request_uri is: http://localhost:8080/foursquare/auth , foursquare will send code as GET request to your application: http://localhost:8080/foursquare/auth?code=CODE This code is then embedded in your request to get “access_token” from foursquare. This “access_token” will be a part of all your requests to foursquare webservice. To get access_token, a GET request is sent:
I suspect they want you to send them a callback URL. But sending them localhost won't work because localhost means "whatever system you are currently on". So to them, its their system not yours.
In any case, until you get your servlet working locally, it makes no sense to send anything to foursquare.
Bear Bibeault wrote:I suspect they want you to send them a callback URL. But sending them localhost won't work because localhost means "whatever system you are currently on". So to them, its their system not yours.
.
Bang on!CallBack URL it is.
Bear Bibeault wrote:In any case, until you get your servlet working locally, it makes no sense to send anything to foursquare.
Start from scratch explaining how you have everything set up. All this talk of foursquare in this topic is a red herring and is merely clouding the issue. You're not ready to even think of sending anything to them.
Pretend none of this topic has happened, and post your web.xml, and how you have the web app structured.
Bear Bibeault wrote:Start from scratch explaining how you have everything set up. All this talk of foursquare in this topic is a red herring and is merely clouding the issue. You're not ready to even think of sending anything to them.
Pretend none of this topic has happened, and post your web.xml, and how you have the web app structured.
Okay, well here goes . This is how I 've structured my web app.So far , the user logs on using the Login.java servlet and is supposed to be redirected to the foursquare site asking him for confirmation . I plan to use the same Login class for the same , as I m able to print the redirection url correctly . And this url also does take me to the required link when I run it on a browser ,however when I run the servlet/project,I get a message saying the 'Page cannot be displayed'
So I'm assuming its something wrong with the web.xml
which is as below
Stop with the foursquare info. It's not relevant until you can hit the servlet yourself by typing the address in the URL bar of the browser. Again, keep the red herrings out of the discussion.
There doesn't seem to be anything wrong with the deployment descriptor as written. But where's the rest of the relevant info?
Where did you place the WEB-INF folder? Where did you place the servlet class? How are you deploying the web app?
Bear Bibeault wrote:Stop with the foursquare info. It's not relevant until you can hit the servlet yourself by typing the address in the URL bar of the browser. Again, keep the red herrings out of the discussion.
There doesn't seem to be anything wrong with the deployment descriptor as written. But where's the rest of the relevant info?
Where did you place the WEB-INF folder? Where did you place the servlet class? How are you deploying the web app?
Well the WEB-INF folder is WebContent and the servlet class is in com.test.foursquare package within the root , Im using an eclipse auto generated dynamic web project structure .I've attached a snip of my structure below. And what other relevant info am I missing out in providing?
Oh, eclipse. I thought you were doing this in the real environment.
At this point I'd suggest either having this topic moved to the IDE forum, or having it closed (my recommendation as this topic went way too off-topic for anyone to try and read from the beginning) and post a new topic in the IDEs forum to get eclipse set up correctly.
That's not an appropriate topic for this forum.
Pankaj Kumarkk
Ranch Hand
Joined: Apr 17, 2011
Posts: 108
posted
0
Do you have only one servlet configured in your system. Can you post the complete web.xml.
The error essentially means that that the server was not able to map the requested url to a valid server side resource.