Session Management in different browsers - java

I have deployed my web application on Tomcat7. There is a form asking some info and starts deploying another application and shows a progress bar and after completion redirects you to the new url.
If in the middle of deployment I close the tab or go to another url and then comes back to my application then I got new form instead of previous page showing my progress.This is happening in chrome and IE, while in Mozilla FirFox things are going perfect.
My question is that can some body tell me what is actually going on in those browsers and what I have to do to tackle this problem.
Cheers

may the reason be in the approach those browsers work with tabs? every new tab for GC is a new system process...

Related

Spring Boot - Automate Web Form Filling on Client side

I'm developing a web app (in Spring Boot) that would need to simplify the user interaction with other websites (third party, not developed by me). The idea is that my app pre-fill a form so the user won't have to do it.
As I began to read about this I stumble upon HtmlUnit and then Selenium... I tried Selenium and I was very happy while I was developing because I manage to open a browser window and fill it as I want it.
Then I thought it would be a good idea to test it from another computer in the same LAN. So open up a browser, navigate to my ip:port and when I hit the button that should perform the automation described, the browser open up on my "server" machine where the app is running and not on the client.
It was very frustrating. Keep reading and I found something about Selenium Hub and Grid. I've read several articles about it but it confuses me because they are all oriented at performing tests and I don't even understand where should I start or if it even possible.
What I want is to have my web-app installed in a Ubuntu Server and any client could access it and when hitting a button open a web page in a specific URL and pre-fill the form data.
Can you guide me? I'm in the correct path with Selenium Grid and Hub or there's any other technology I should be using?

angular application getting an error from a tomcat application

I have an angular 2 application that makes http get calls to a tomcat server (Java).
when I make the call, in the browser console, I see a long error ending with
Not sure what the cause is and what the solution might be.
Anyone dealt with this before?
Sorry, JavaScript must be enabled in order for you to use this application.
In case you have error JavaScript must be enabled... than you need to turn JavaScript on.
Go to Delop tools (F12) and go to settings in the top-right corner of the window.
In preferences go down to Debugger you will have checkbox to Disable JavaScrip

Simulate opening web page - Java

I want to simulate opening a web page in java, I know I can do this to actually open the page in my browser on my computer,
String htmlFilePath = "path/to/html/file.html"; // path to your new file
File htmlFile = new File(htmlFilePath);
// open the default web browser for the HTML page
Desktop.getDesktop().browse(htmlFile.toURI());
// if a web browser is the default HTML handler, this might work too
Desktop.getDesktop().open(htmlFile);
But is there a way to simulate it so I don't actually see it open on my computer, but it still evaluates like someone did open the web page.
Or if that is not possible what would be the easiest way to physically open it on my computer and then have a way of getting a callback so that I know when the page has been loaded?
Thanks
There are several ways to emulate an HTTP client (such as a web browser):
Jersey (Java) - https://jersey.java.net/documentation/latest/client.html
Apache HTTPClient (Java) - https://hc.apache.org/
JMeter (Java) - Use JMeter to record an HTTP request and replay it as a test - https://jmeter.apache.org/usermanual/jmeter_proxy_step_by_step.pdf
Selenium (browser plugin) - http://www.seleniumhq.org/
CURL (command line tool) - http://curl.haxx.se/
I do recommend Jersey in your case. It is a tool especially designed for REST. So it may even help server-side development.
I know you specifically asked for a Java solution, but the last two options are really popular.
I have a sample program here that uses the Selenium library.
Launch Firefox and Wait until it is Closed
The program has a code that launches a browser and opens a website. It can detect if the browser has done loading the website. It can also detect if the browser was closed.

JavaEE application throws HTTP 408 when debugging application with eclipse

currently I'm starting to learn JavaEE. I created a simple donation-management-system which is secured by a login form. In the past I've just deployed my code to JBoss AS 7.1.1 and accessed it via browser.
However I would like to debug my application using Eclipse, as my application is starting to get bigger. I found several tutorials on the web and here at so but they didn't bring the expected result.
Here is what I did:
I edited the "standalone.conf.bat" and uncommented the line
set "JAVA_OPTS=%JAVA_OPTS% -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n"
Then I created a new "Remote Java Application"-Configuration in Eclipse using localhost as hostname and 8787 as port.
Now my problem is as follows:
When I try to debug the application, the integrated eclipse browser opens up and show the expected web page, but when I enter the credentials and click "Login" I this exception:
HTTP Status 408 - The time allowed for the login process has been exceeded. If you wish to continue you must either click back twice and re-click the link you requested or close and re-open your browser
When I open my application in f.e. Firefox everything works fine.
Any ideas how to fix that? I'm already getting grey hair..
Edit: For the Login-Form I use the j_security_check
Could potentially be an issue with the integrated browser in Eclipse. Perhaps it's not handling session cookies properly.
To eliminate that possibility, I believe that in your general Eclipse preferences you can change the "Web Browser" setting to an external web browser (like Firefox) and see if you still have the issue.

Open html in browser from Java. Bug if browser is not started?

I am using
java.awt.Desktop.getDesktop().browse(uri);
to show my users a generated html file. All is fine if the browser (firefox 3.5.7; linux) is started before I make the call. But if the browser start is triggered from the getDesktop().browse call then the java application will not exit until the browser closes.
How can I avoid this behaviour? Is this known under windows/macOsx too?
(If I then force the exit of the java application the browser will close too and sometime even crash!?)
The reason the browser exists is because the browser is launched as a dependent process...so when the first process shuts down, all its dependent processes are shut down with it. But in the case when you start the browser first, it already has a different process ID that isn't affected by your application. I think the only way to avoid this behavior is to use a different technique (perhaps Runtime.exec()?) to launch the browser in a way that registers it as a non-dependent process.
The project Browser Launcher (http://browserlaunch2.sourceforge.net/) can be the solution for your problem. You can launch a browser from your code like this:
String url = "http://....";
BrowserLauncher() launcher = new edu.stanford.ejalbert.BrowserLauncher();
launcher.openURLinBrowser(url);

Categories