I am currently implement a facebook login in my application, after the user has successfully authorized his or hers account, it would go back to an action class in my web server and on that.
Here's an example
1)User clicks logged in with facebook
2)He or she will be redirected to this facebook authorization page
2) Once he or she has been authorized.the page will then be redirected to struts2 action class.
so the url will be looked like this
http://127.0.0.1:8080/MyApp-Facebook/oAuthExchange?code=SomeLongFacebookCodHere#_=_
if you will see the ending url of oAuthExchange has a #_=_.
and then it will be redirected to the dashboard page of my app the page url will looked like this
http://127.0.0.1:8080/Struts2-Facebook/dashboard#_=_
if you'll notice there is a "#_=_" in my URL. is there anyway I can remove the "#_=_" when I do a redirect?
I am also using Facebook4j for facebook graph API
You can remove it directly from the result page in HTML5 compliant Browsers with history.pushState().
Assuming #_=_ is fixed (otherwise you need to perform a dynamic substring with indexOf looking for #),
put this in your page:
<script>
//4 is the lenght of #_=_
var cleanLocation = location.href.substring(0, location.href - 4);
history.pushState("","", cleanLocation);
</script>
Related
I have to crawl the elements in the index page, to do that, I have to log in then navigate to the index page, how to solve this using Jsoup and Java.
Step 1: Login: (how to connect my user name and password with the fields inside the login page).
Step 2: After successful login, navigate to the index page, then crawl said elements inside the index page.
Maybe you can fetch the index page with cookie. To fetch cookie, Press F12 after login using your browser.
I have a SpringMVC application i am not sure if its working properly. I have a registration form the url reads http://localhost:8080/myapp/registration.htm when i click on the query button the application is posted to the controller and the user is posted to a second page getList.htm which displays a list of results however when posted to the second page the url still reads http://localhost:8080/myapp/registration.htm.
When the second page is posted the user is suppose to be taken back to the first page http://localhost:8080/myapp/registration.htm to display the record selected form the getList.htm (this displays multiple records).
When the user is posted back to http://localhost:8080/myapp/registration.htm the url reads http://localhost:8080/myapp/getList/1985121244.htm where 1985121244 is the record number. Should the url be displaying http://localhost:8080/myapp/registration.htm once the user is posted back to the first page?
Also if the user tries to POST the first page after being returned form the getList.htm POST you get a HTTP 400 and the url reads http://localhost:8080/myapp/getList/registration.htm. The second page is appended to the url and this is not an appropriate mapping in the controller. Can someone explain what is happening here and how is it fixed.
Edited
Also when i first enter the application the main menu is http://localhost:8080/myapp/hello.htm when i click on a a href i am taken to the registration page however the page shows but the url does not change. When the href tage is clicked form the hello.htm page the Controller makes a reguest to get the registration page and returns it using return new ModelAndView("registration"); i saw some sites that say i should use return new ModelAndView("redirect:/registration"); However when that is used i get 404 Not Found - http://localhost:8080/myapp/registration". Any ideas anyone on what i can look at before i post code my code is alot
For me it looks like you just return view name after login. Of course that doesn't change your url. Instead of returning view name use "redirect:/getList.htm" pointing the url you need.
Then controller which processes the getList.htm checks whether user is logged in and return proper view name.
I want to redirect the users to the login page when some inter error has occured. Javascript function has got the response as internal error so from this javascript function I want to redirect the user to Liferay login page. what function should I call to achieve this?
Change href property of the location object when you need to redirect browser to a new page:
location.href = '/login/page';
I am creating an application using Grails/Groovy that will contain an iFrame which the user can browse in. I would like to be able to store the URL that the iFrame is currently on in a string property (currentSession) on the users account so it will automatically return to this page the next time the user logs in..
I just don't know how to retreive the URL of the iFrame so it can be saved to currentSession whenever the user logs out.
Thanks in advance.
I think you would have to grab the iframe URL with javascript and post it to a Grails controller, which has access to the current session.
Perhaps something like this (asuming you're using jQuery as your Javascript framework):
<g:javascript>
var iframe = $('#iframeid')
var url = iframe.attr('src')
$.post('${createLink(controller: 'some_controller', action: 'some_action')}', {ur: url})
</g:javascript>
and then make a controller - ask if you need help with that :-)
It must be done using JavaScript, for example:
var frameUrl = document.getElementById('_content').src
where _content is ID of target frame. frameUrl will contain URL of document in frame
I guess you know how to send it to server?
I am using user service to let the user login and logout , i want to make something like google bar at the top of the page which contains logout + your email, when ever you access any page you can find that bar .
Certainly i use that user service and checks whether the user has a full access to enter the page if so then i use div id="my page" else create a login URL , even when the user has been authenticated correctly he enters the page and when ever he clicks on a link he goes to another page (in the page i also use user service and login and out url ) here comes the problem when the user clicks logout in that page and try and login again he goes to the second page where he has clicked the logout URL not the home page , i want the user when ever he clicks logout he and try to login again he goes to the home page
From the last line of your question, it sounds like you just want the logout button to go to the home page. From the Users Java API - why not just do userService.createLogoutURL(homePageURL) (substituting homePageURL accordingly)?