Enable JavaScript inside Java Applet - java

So, I have made a proxy-like Java Applet. It lets you navigate a site, handling cookies an everything, and supports authentication on the remote site. The thing is that after logging in on the remote site, I try to navigate by clicking the links and it complains that I have JavaScript disabled. To clarify, the site is functioning perfectly well when accessed directly.
My question is, can I somehow enable JavaScript inside my applet? Is it something that has to do with the browser, is it some HTTP header I must include? Am I missing something in the picture..?
Thanks in advance! :)

Related

Java - reading data from website requiring login

I'm basically trying to use Java to read some data from my school's website (homework assignments, which lessons I have and when, etc.) for personal use. However, my school requires one to be logged in to access this information.
Could anyone point me in the right direction for logging in with code and accessing this information?
Thanks,
Mike.
The Apache has a API for http client simulating.
Link: http://hc.apache.org/httpcomponents-client-ga/
You need to find out how the server handles logins. What authenticationer it used: cookies, url session id, etc.
Then you can send the server a login http form submit (as you would have done manually) and save the authenticationer.
With the authenticationer you can then access the secured sites.
I would use HtmlUnit, which is a programmatic web browser.
You tell it to load the authentication page, to fill the form with your credentials and to click on the submit button. The you click on links, just as you would do it with a real browser, but programmatically, using Java instructions.
And it even supports JavaScript, if necessary.

How to get correct page on site that doesn't change URL

I need to go around a site using java programmatically but the site doesn't change the url when linked is clicked.
Site: http://cliqa.nana10.co.il/
On the right you have a bar with some links, click them and you will see that while the content changes the url doesn't change. how can i achieve programmatically this mouse click on one of the links in Java, I thought about HTTP POST but what exactly I'm going to send? an example would be much appreciated.
These links use JavaScript to trigger an AJAX request and refresh only the center of the page. Use FireBug inside Firefox to sniff the network requests and see which requests are executed on each click. Or use a programmatic web browser like HtmlUnit which will handle JavaScript as your web browser does.
You need to look at the actual HTTP request being sent. You can do this Chrome with the built in Inspect Element tool or Firebug in Firefox (or Live HTTP Headers). I prefer to use Burp Suite's intercepting proxy to see this.
You can try charles (http://www.charlesproxy.com/). Check the section on JAVA APPLICATION PROXY CONFIGURATION at http://www.charlesproxy.com/documentation/configuration/browser-and-system-configuration/. You can inspect and change request sent from your java application.

is there some way to enable cross-site javascript, either in browser or in browser embedded within java application

I am creating an application in which there will be multiple iframes within the main window- forms will be opened for submission in the main window and each form's target iframe will be one of the many iframes available...
I want to be able to access the response of each form submission, i.e. I want to access content in child iframe from code in the main window.
Please clarify the following for me-
(1) As I understand Same Origin Policy does not permit the above scenario? Am I correct?
(2) Is there some way to enable the access to child iframe, that i require, in any web browser? I saw some posts on SO about this, and even tried some of the solutions, but nothing works (I tried Google Chrome, Firefox 6, Firefox 3.6 and Safari).
(3) In case its not possible to get such data access in browser, then can I get such access by embedding a browser component in my java desktop app? In such case which browser component do you recommend?
Only if the content of the child iframes is loaded from another domain.
Generally not. In some newer browsers, the target domain can use HTTP Access Control headers to allow cross-site requests to be made to it, but there is no way for the source site to make that decision.
I'm not familiar with Java browser components, so I'll let someone else answer this part.

How do you set javascript as enabled when using DefaultHttpClient?

Im trying to use DefaultHttpClient to log into xbox.com. I realize that you cant be logged in without visiting http://login.live.com, so I was going to submit to the form on that page and then use the cookies in any requests to xbox.com.
The problem is that requesting anything from live.com using DefaultHttpClient returns the followings message.
Windows Live ID requires JavaScript to sign in. This web browser either does not support JavaScript, or scripts are being blocked.
How do I tell DefaultHttpClient to tell the server that javascript is available for use? I tried looking in the default options and also adding it as a parameter object but I cant see what I've got to do.
The reason this is happening is that this line of HTML is getting parsed from live:
<noscript><meta http-equiv="Refresh" content="0; URL=http://login.live.com/jsDisabled.srf?mkt=EN-US&lc=1033"/>Windows Live ID requires JavaScript to sign in. This web browser either does not support JavaScript, or scripts are being blocked.<br /><br />To find out whether your browser supports JavaScript, or to allow scripts, see the browser's online help.</noscript>
Which is used to redirect you if your client does not have javascript enabled (and therefore will parse <noscript> tags.)
You could try to use a less intelligent HTTP library which does no parsing of the content, but which instead simply does the transport and leaves the parsing to you.
Use Wireshark to trace the communication using both a browser and your program, and look for the differences. It's hard to say what, exactly, live.com/xbox.com are looking for, but there is likely some AJAX-y code used to get the actual content.
Windows Live ID requires JavaScript to sign in. This web browser either does not support JavaScript, or scripts are being blocked.To find out whether your browser supports JavaScript, or to allow scripts, see the browser's online help.

Issue with IE security on page opened from javascript

I have a Java web application running in JBOSS with Tomcat with two web applications (contexts) running on it.
A button press on one of the applications opens runs a javascript command to open a new window with a page from the other.
The problem I seem to be having is that this raises a security alert in IE. with the following message:
I can't really ask my customer to add an exception to "http://" what are the likely causes for it not picking up the site?
The browser is correctly pointed at the full url for the page (Ie www.something.net:8080/blah/somepage.jsp) the browser is IE7 with enhanced security running on windows 2003.
You need to uninstall "Explorer Enhanced Security", which is on by default in Windows Servers, before IE will act like a normal browser. :)
Workstations shouldn't get this problem.
IE Enhanced Security Configuration is deliberately designed to prevent general purpose browsing from servers. Folks who want to do workstation-style browsing and just happen to be on a server SKU should disable ESC.
What's the exactly line of code? window.open("http://fullURL", etc), or something like var v=window.open("about:blank"); v.location.href=etc ?
Do the two applications have different domains? IE is preventing the cross-site scripting.
Can you not just have a link to the other site?
EDIT: If this is on Windows Server 2003, then the only way that I've managed to get around it is to disable to enhanced browser security. If this is the case, then you shouldn't really be browsing from a server in the first place.
Edit2:I'm guessing that it is the enhanced browser security that is doing this.
Check out this link: http://support.microsoft.com/kb/815141 on info about it.
Your choices are to either to disable it, add an exception for that site, or use another browser.

Categories