I'm using JSF 2.0 and Glassfish 3.1 and have the following problem:
I've got an application in which two users must participate. The first user should set up the session and then get to a wait page. When the second user joins, the first one should be redirected to the application page. Is this possible in JSF, and if yes, how?
Create an Ajax polling mechanism
Invoke an action from Ajax, check if condition met
If met using JavaScript code redirect the user (Or you can also make it redirect from action)
Related
I have an tomcat server application where in a HTML form is displayed. Once I submit the data the page redirects to another page. In the back-end there is a JAVA program which takes some hours to complete execution. In the mean time if some-one tries to open my HTML page displaying form(First page) from another browser or another tab, it has to redirect automatically to the execution page. Is it possible to do this with Tomcat Server and JAVA? (I am using it on RHEL machine. So please do not post platform specific solutions.)
Here is an approach:
Introduce a flag in your server side code to determine whether the multi-hour-job is in progress
Whenever backend job is started, set the flag. When job done, reset the flag.
Either in your servlet doXXX method or in a servlet filter, check flag if set then redirect, if not then return the form view
On my MVC spring application I send a form to a page using post method to perform a search with some parameters. The results of the search is a list and, for every entry is possible to navigate to a details page. It works fine but, when an user try to come back to result page with back browser button (or a Javascript), I get an "Expire page" error. Refreshing the page, it rexecutes the post submit and it works fine.
To prevent this error I added
response.setHeader("Cache-Control", "no-cache");
to the search controller and everything works fine with Safari and Firefox but I get the same "Expire page" error when I try to execute the web application with IE (8 and 9).
What's the right way to go to a detail page and come back without getting any error?
thanks for your time!Andrea
The right way is to use GET instead of POST: searching is an idempotent operation which doesn't cause any change on the server, and such operations should be done with a GET.
Not expiring a POST request seems to undermine the very idea of a POST:
Per RFC 2616, the POST method should be used for any context in which a request is non-idempotent: that is, it causes a change in server state each time it is performed, such as submitting a comment to a blog post or voting in an online poll.
Instead, I would restructure how you view the detail records, maybe with an overlay DIV that doesn't refresh the underlying page that shows the results. With many modern web apps, using the BACK button can cause issues with page flow.
Redirecting application link to Java - GWT Custom page.
Whenever user will login through my APP.
and user hit button(say add record) then redirection should happen i.e. page should redirected to GWT custom page from application link.
How to call servlet when application link hit by button?
after that How to call GWT page from called servlet.
Wants to show GWT custom page with data present in REQUEST.
Hidden fields available on UI Screen which is developed in GI .
These fields can be passed to GWT custom applications launched from the application link.
APP(UI) --> SERVLET---> GWT page(UI with data present in request i.e jsessionid,hidden fields)
what changes need to do in web.xml ?
Plz provide any helpful document,link,sample code and any idea
Hope for the best co-operation
Thanks in advance.
Do you already have a fixed login page (servlet) tah you must use? Then do this:
Window.Location.assign(loginUrl) will take you to a new page. Your GWT app will be "closed" and all state will be lost.
Your login servlet should redirect back to your GWT page when done. Usually this is done by supplying a URL parameter when invoking login page - check the login servlet. Usually something like http://yourserver.com/login?returnTo=GwtAppUrl.
At this point your user is logged in, which means that servlet has set a session cookie. From this point on (until logout or session time-out) your GWT and GWT-RPC will use this session automatically (browser sends session cookie) - you don't have to do anything.
You can pass some data back to GWT by fragment identifier http://yourserver.com/login?returnTo=GwtAppUrl#somePage/parameter1/parameter2. However better option is to just use GWT-RPC to get the data from server.
Otherwise, if you are making everything from scracth, you can use GWT do do the login: How to implement a login page in a GWT app?
Is there any way to open a popup from a servlet
I have an asynchronous process running , and I need to somehow notify the user when finished, without having to refresh the page
any ideas ??
"Without having to refresh the page"
That's what Ajax is all about I suggest that you take a look to some Ajax enable JSF framework, like Richfaces, if you're using JSF 2.0 you can use Ajax behavior by default.
With Richfaces you can use the <a4j:poll> to check after some period of time if the asynchronous process have finished, you can then re-render the appropriate message.
<a4j:poll interval="1000" enabled="#{notificationBean.isTaskComplete}"
reRender="completeMessagePanel" />
Thats the general Idea.
To implement single sign off, i would like the user to get logged out of application B additionally when ever the user clicks logout on application A. Is it possible to implement this using some form of a POST request to application B? i.e. when the user clicks on logout:
Generate existing POST request to logout of application A
Generate additional POST request to logout of application B as well.
The cleanest way to do this is to check if your SSO provider has a single-sign-off feature.
Coding this up and deploying it would make your overall IT solution a bit brittle.
Another suggestion is to take this up with your (Enterprise) architect as SSO is usually an enterprise initiative and point her to (very cogent) arguments in this post : http://lists.danga.com/pipermail/yadis/2005-July/001085.html
Yes, how you do it depends on the programming language you are using.
For example under ASP.Net you'd use System.Net.HttpWebRequest within the handling of the Logout event of application A to make a logout request to application B
If you can post what language you're working in I can give a proper example
Depending on the implementation of your authentication system, probably you can/need to send the POST using JavaScript instead of from server-side.
Without specific information, it's hard to give a specific answer, but as you're refering to POST, I'll assume a browser is involved.
POSTs (without using Javascript or similar) occur when a form is submitted. As the form can have only one action, it can only target one server-side page.
One solution is to simply have Application A forward sign-out credentials to Application B once one action is received, which allows for more opportunities to check returns.
If, however, you're set on POST'ing to different pages, see this tutorial for one iframe-related hack - http://www.codeproject.com/KB/scripting/multiact.aspx
If your login session is stored by a cookie, and there are nothing else you need to supply to log out of application B, clearing the cookie in javascript will usually destroy the session and sign the user out.
How about making it a cookie based authentication? A same cookie authenticates a user for various applications (in your case 2 different application.) Once a user sign off from one application (app A), invalidates a cookie (by expiry date) so that whenever a user sends a POST request to rest of the application (app B) the request is not processed. A Servlet that traces each POST request to validate the cookie is required for each application.