Triggering a web page print from server side - java

This question might be very basic.
Till now I thought a command to print a webpage can only be initiated at the client side.
(window.print when using javascript)
But I came across http://juixe.com/techknow/index.php/2008/01/17/print-a-pdf-document-in-java/ which states about printing using Java. I think this seems to be related to some desktop client and the same may not be possible in a web client. Can anyone confirm and explain this?

You can't execute server side code on the client, so the only way to do it in browser is through javascript or using plugins/flash/java applets.
You could print using java, but for that java needs to run on the client.

A website can ask the browser to open its print dialog (Google Maps does this on the "print directions" page, for example), but it can't actually force the browser to print anything. (If it could, you can be sure that advertisers would use it to print ads on your printer.)
A Java application running locally with sufficient permissions can print, just like any other desktop application. That has nothing to do with web pages.

Don't confuse Java and JavaScript. When trying to use Java within a browser, you'd have to look into using applets. A Java applet could definitely be used to do the kind of work you'd normally have a rich client do from within a browser.
Java applets could also receive events sent out from a server via sockets or some other mechanism, although I'm not certain if security constraints would allow it. Also seems a bit of a roundabout way to do things.
Remember that web browsing is a client-side-driven affair. There's some push models in certain infrastructures (I believe it's possible using JavaServer Faces). But those are probably just a sort of polling mechanism initiated by the client that is abstracted away to look like a server-side push.

Related

Java - Go to new url in new window/tab

I want to be able to use Java to tell it to go to X url when X browser is open/running (my lingo is terrible). (Firefox/Chrome/IE is already up, and I want it to go from the default page to let's say Twitter.)
Most of the solutions are using java.awt.Desktop to launch native browser with a url in it, but that isn't useful if I want to change the url later on. (Already on Twitter-Home Page, but want to go to Twitter-Contact Us afterwards.)
The other solutions I've seen involve using Selenium WebDriver, but I also need to eventually learn how to basically force the Java to read a long list of URLs off an excel and simply verify that url isn't dead, and then do this on the Native Android browser, for example. So the Selenium might not be the right choice. Granted, you can also tell me this is an awesome choice for this too if it truly is. I haven't really been exploring Selenium.
Sorry for asking such a basic question. Company wants QA Automation without training/hiring an Automation QA. My end goal (aside not getting canned), is to see if I can get a bunch of urls to load on specific browsers. I can sort of (praying) be able to do stuff with it afterwards.
A simple trick would be to create an add-on( if you know javascript ) which will be quite similar in chrome and firefox (for IE I have no idea in my days it needed BHO) and send websocket commands from java to your addon. But this needs a java websocket server running where your addon will connect when the browser opens. Rest of communication can be carried upon the protocol lines of your requirements.
There are multiple parts to your question.
Read urls from excel.
Use Apache POI to do the same. Selenium code can use the same.
Check that the urls are not dead.
Use any java http client, (apache) to do that without even opening a browser. If the link is dead, it will be dead for all the browser.
Open the links in a multiple browsers.
Selenium is perfect for this. I am assuming that after the page is loaded you have way of validating that the page is correct. Selenium is very powerful here.
Target native android browser too.
I do not know of much difference between this and the previous question unless you are also testing site display based on browser size. The browser is more or less the same as chrome with webkit rendering engine.

Authenticating from PHP to Java and retrieve data via WSDL

Ok, so I inherited a project where our core program is built by another company (built in Java) and I have to build another program around it. Problem is that the Java program has to stay as is and I am only allowed to authenticate through to it and pull the findings once users go through there. I am not even sure what to ask for cause I've never cross authenticated before nor used a WSDL etc...
I am an intermediate/advanced PHP coder and would have rather built the entire thing from the ground up (it would be faster and customizable) but, i can't. this java application needs to stand on its own--maybe in an iFrame--and once our users sign into our site, they need to automatically signed in there so when they click on it from the panel, they perform their actions which mark them complete there. We read their completion and mark them complete on our side (via PHP). Their develops have a WSDL file that supposedly we pass the information and we can read their completion and status stuff. No idea how to use it.
The dev environment is IIS 7 (im more used to linux and unix environments)
Any idea where I should start? How to do this? What questions I should ask their developer for so I can develop the PHP side of things?

Java applet socket server permissions

I want to make a Java applet, which functions as a socket server (local network ips, or 127 range is fine).
I want this applet to run in a webpage.
the browser can ideally load the webpage from the file system (file://...), but I could install an HTTP server if required.
The applet will need to be able to interact with JavaScript.
I'm having trouble wading through all the docs. Is the above possible? I'm not familiar with java's security model. If I need to sign the applet, or set some special security or configuration settings, that's fine.
edit-
In case anyones curious, the applet does very little. I just want to use it as a bridge so that another program running on the local computer can communicate via sockets. That program supplies values, which javascript will use to update the ui in real time. The ui is complicated, and building it in html/javascript will be a huge time saver. I'd prefer the applet function as the socket server opposed to a socket client, because otherwise then I need to write a seperate program to act as a server in between the applet and the other program.
Is the above possible?
Sure. If you control the security/policy files for that applet & the firewall, it is a single browser deal, it should be doable. You might need to wrap some of the applet methods in a PrivilegedAction if called from JS.

Looking for some information in getting Java to communicate with a website

I was wondering if one could write a Java application and put it on a website and then have it running so that when a user used your website it could interact with some html/javascript page which would communicate with the Java program.
So basically, the html5 would be used to display the java program but all the logic and everything else would be server side in Java.
I don't want to use a java applet since it requires users getting a security warning and most browsers do not autorun a java application. I just think it would look cleaner and work nicer.
Does anyone know anything about this and could give me a little abstract just to point me in the right direction so I can learn more?
Thanks
It's somewhat difficult to tell from your question but you might find GWT useful. You code everything in Java, and the client-side portion gets compiled into html/javascript which communicates to the server portion with AJAX. http://code.google.com/webtoolkit/
I think you should start by developing a simple Java web app using html, jsp and servlet. Try the Google App Engine for deployment as it is free for hosting.
http://www.servletworld.com/servlet-tutorials/simple-servlet-example.html

Screen scraping with Java and X3270

I have been trying to use Java to connect to X3270 (actually, wc3270, since I'm working on a windows environment) and control it to access a mainframe, login, navigate a few screens and get the data returned from x3270's command "ascii" for further processing (like separating the needed fields).
Even if I can connect to x3270 and login into the server, I'm having trouble to reliably retrieve the screens from x3270 after sending a command, even using threads to read the socket continuously.
Can anyone tell me what I should be doing to get things right?
I cannot more highly recommend Jagacy 3270, a Java screen scraping library that's incredibly reliable and dead easy to use. I had tried rolling my own, and also both IBM HATS and IBM Host on Demand, and found Jagacy to be easy, quick, lightweight, and already done for me.
A full license isn't cheap, but was worth it to us.

Categories

Resources