All,
I have been looking for this answer for several hours and I cannot seem to find a lot of great information.
I have been provided a URL to a JNLP file, which is opened via JavaWeb start.
When this application open, it has two fields. One for a username and one for a password. I can manually enter data into these fields and the application redirects me to where it should go.
My question is, is there any way to programatically access these fields for automation purposes?
There seems to be limited information on the subject.
Any assistance or pointers in the right direction are welcome.
Thank You
Related
I am trying to write an autotest for authorization in e-mail, but due to the fact that the login window is built dynamically, it does not come out to take the path to the text field for text input. I will be glad of any help. Thanks!
I tried all possible ways to it, but none of them worked
I know my question is more likely to be discussed rather than really answered (because it's very large), but I need some elements and "advices" to really get started, sorry for that.
So I've got a java program which has to analyse some URLs, I've finished this part. For the moment, the user has to enter manually the link into my program, then the link is analysed.
Now I have to retrieve automatically those links, which will be sent to me via e-mail. (In a special Gmail inbox created for that purpose)
So I need to :
Let my Java program "listen" to my inbox
Extract the link of any new mail in order to analyse it
There are many problems, according to the way I choose to access to my inbox (POP3, GMail API...), according to the frequency my application would check the inbox, maybe there would be authentification problems... Even how to let my application run as a "daemon"...
And I really don't know how to get started, which choices to make etc.
Any help is welcome of course, if you have any documentation or else. Thank you in advance.
You have several ways of doing this.
I suggest you using Java Mail, that has a simple and useful API.
You have some documentation and examples in this URL:
https://java.net/projects/javamail/pages/Home#Samples
Look at the class monitor (very bad name!!!) inside the examples. This class monitor a mail box for new emails.
I've recently been working on an enhancement for an application at work that will allow users to delete presentations stored not on their local machine but on a Linux server present on the internal network. My problem is that I am not sure how to go about performing this delete. The location of the files are as follows:
http://ipaddress/dataconf/productusers/**ACCOUNT**/presentations/
I have access to the ACCOUNT name which is a parameter that will need to be passed in to navigate to the right directory. I will also have access to the presentation name which will be needed to specify the correct presentation to delete.
What I am having trouble with is where to begin.
I am using the Spring framework so my code is a mixture of Java, JSP, and JavaScript.
Essentially I have a .jsp page where I layout the presentations that are associated with each account. I.E when you click on an account it makes a call to a database and lists the presentations that are associated with that account. You can then select individual accounts and delete, or press one delete all button and delete them all.
I currently have it working so that when you delete a presentation in my application, it deletes the appropriate record from the database, but I also need to delete the physical presentation which is the basis for this question. Just as an FYI, these requests (get presentations from database, remove presentations from database) are all being handled through AJAX and JSON.
I am hoping to learn how to create a connection to the correct server, navigate to the proper directory as specified above, and issue the Linux command "sudo rm file-name" all in the same delete process that I described in the prior paragraph.
If you could point me in the right direction, any help would be much appreciated. Also, if you need any further clarification please feel free to let me know.
Thanks again,
Dave
This will not be easy. Or maybe it will. Please understand first that simply knowing where some files are published on an HTTP server is basically useless in terms of manipulating those files.
So I understand the following: You have your own web application on server A, a database somewhere, and some files located on another web server B. Internally on server B, the files will be in some weird directory e.g. /var/www/docs/whoknowswhat/somefolder/dataconf/productusers.
What you need to do is to somehow expose this folder from within server B over the network to your server A. Talk to your admin people. Maybe NFS is an option, or maybe Samba, or SSHFS. Make sure you have write permissions, and also make sure that noone else does.
Once you have mounted the location from B in your server A and it is available to you as some directory /mnt/serverB/productusers, then all you have to do is something like this, i.e. File f = ...; f.delete();
I did a little research and stumbled upon a neat solution to accomplish what I am trying to do. If you take a look at the following link:
http://www.journaldev.com/246/java-program-to-run-shell-commands-on-ssh-enabled-system
The above site describes a method in which you can open an ssh connection in Java and execute commands as if you were running them from the terminal. It has come in handy for my problem and I hope that if anyone else is experiencing the same problem that this will help them as well. Feel free to let me know what you think.
Although I've been programming for a few years I've only really dabbled in the web side of things, it's been more application based for computers up until now. I was wondering, in java for example, what library defined function or self defined function I would use to have a program launch a web browser to a certain site? Also as an extension to this how could I have it find a certain field in the website like a search box for instance (if it wasnt the current target of the cursor) and then populate it with a string and submit it to the server? (maybe this is a kind of find by ID scenario?!)
Also, is there a way to control whethere this is visible or not to the user. What I mean is, if I want to do something as a background task whilst the user carries on using the program, I will want the program to be submitting data to a webpage without the whole visual side of things that would interrupt the user?
This may be basic but like I say, I've never tried my hand at it so perhaps if someone could just provide some rough code outlines I'd really appreciate it.
Many thanks
I think Selenium might be what you are looking for.
Selenium allows you to start a Web browser, launch it to a certain website and interact with it. Also, there is a Java API (and a lot of other languages, by the way) allowing you to control the launched browser from a Java application.
There are some tweaking to do, but you can also launch Selenium in background, using a headless Web browser.
as i understand it you want to submit data to a server via the excisting webinterface?
in that case you need to find out how the URL for the request is build and then make a http-call using the corresponding URL
i advice reading this if it involves a POST submit
A pretty basic JSP question, since I'm still trying to understand the right way to do things.
I'm working on a web app which requires users to log in before working. What I'd like to happen is, anytime a user that isn't logged in tries to access any page (other than the login page), the user will be redirected to my login page.
The approach that I've chosen is just to have a bit of code at the top of each page, attempting to grab the user object from the session, and if it doesn't exist, redirect to the login (I have a User object stored in the session for users that exist, which contains other details like permissions).
Is this the proper way of going about doing authentication? Or are there more standard ways I should be looking into?
EDIT: I decided to split this question into two questions, since one was more of a best-practices question and another was a purely technical one. Thanks for the responses.
I don't know whether you have this alternative, but using the Java EE declarative security would free you from needing to put authentication code into every JSP.
The idea is that in your web.xml you specify security rules, such as: this URL pattern can only be accessed by users in that role.The container will then challenge when users attempt to access the protected resources. You can specify your own login page for use when the users are challenged.
I think this is much perferable to coding your own login.
Here's a link to a description of how to do this.
Yes, JSPs are compiled down to servlet subclasses. The proper way to return early is to simply place a "return;" in your JSP.
Having said that, I think you should consider other authentication solutions. Its very easy to end up inadvertantly forgetting the include at the top of 1 JSP, and then you end up accidentally allowing GUEST users on that page!