Uploading Files with different formats to a URL using Java client - java

I need to write some code in Java to upload a file(.tz format) to a URL(prqs#vks.com) by using HTTP PUT/POST and SMTP.I have no idea how to do this and my application is not a web based application i have to write a pure java client to do this. I searched the net but could not find a suitable tutorial on how to do this also i found a lot of stuff where in they are uploading file using a HTML form to a server. but that is not what i want.
Can you please let me know how this is to be done. If you can direct me to a tutorial or provide any sample code then it would be very helpful. I am scratching my head on this for a long time now.
Thanks
vikeng21

I do this all the time from a server side Java Application.
If what your asking for is creating an e-mail with an attached file in .tz format then there are some good resources out there.
I personally used the JavaMail API. It comes with attached JavaDoc and examples. Take a look at the samples in the demo directory within. Hopefully it should help you out.
Java Mail API

You can try out Apache Commons Fileupload for uploading files.
Have a look at this example as well. This might work for you

Related

How can I stream video to a browser using Java/Spring?

We a have jboss server running and have a basic web setup using Spring but now I would like to stream video into the browser. I am trying to use xuggle but then I read on their website that you can't put it into an Applet or use it with java webstart, so I'm assuming that means I can stream to a browser, is this assumption correct? If so does anyone else know any libraries or how I should go about doing this? If you need any more info or have questions I'll be happy to answer although I'm very new to streaming video and relatively knew to Spring.
UPDATE: So I'm able to generate a video using xuggle, and then I can embed that video in my html code... but I can't generate and stream at the same time. Does anyone have any ideas how to make xuggle push date out to my tomcat server?
You may want to look at Red5 media server.
Since you are doing jsp, just have your code write out the HTML 5 video element. That will provide basic video functionality. This will work in all HTML 5 compliant browsers as well as all mobile devices.

Java upload file (image specifically) from a JApplet to MS MVC page

I am going mad trying to find an example of file upload code in Java that will enable me to submit (POST) images to a URL from a JApplet in the same manner that an html form would post a multipart form. I have found loads of examples referencing servlets, jsp, apache but this is no good to me as my applet is being displayed in a Microsoft MVC 2 .Net project on IIS 7
Surely there has to be a simple way to do this - I am using jnlp/webstart and have no issues accessing the files I want to upload I just can't seem to find a simple sample to get me underway.
Any feedback/tutes greatly appreciated, I am happy to be pointed in the right direction in regards to the appropriate Java classes/methods - this will at least give me a starting point.
Cheers
Rob
Short Pointer: Use URL, URLConnection, setDoOutput(), and getOutputStream().
Actually it got the better of me and starting googling again but this time for Java Submit Form rather than Java File Upload and I found this great class that I have just confirmed works correctly with great abstraction of the painful intricacies of this process.
http://www.devx.com/Java/Article/17679/1954

How to talk to Tomcat server from a PHP application

I am developing a new report engine for my company, our main web application is writing by PHP 5 and running on an Apache server. The new report server which I designed to use Apache FOP 1.0 ruing on Tomcat7,so far I created My own XSLT stylesheets and I can manage to generate a PDF report from the URL and let it display in my web browser.My goal on this project is to generate dynamic report from xml file which export from the PHP application.
Could anyone explain to me the logic behind How I can give those two talk to each others. I understand I could POST the XML and XSLT as string to the report server and POST it back the result I want(like PDF).
I know this will need Java involved,and as a PHP dev. I really don't have much background about Java,if you could show me some examples or links, it would be much appreciate.
I am using Saxon-B with Fop 1.0 on Tomcat 7 for the report server.
if you need more info from me,please also leave a comment. I will add it soon.
Thanks
There are two things your going to need to study.
http://www.w3schools.com/php/php_ajax_intro.asp This is a tutorial on using the XHR object from php. You should go through that. Also, if you aren't familiar with the XHR object, I would read this as well: http://www.w3schools.com/XML/xml_http.asp
You're going to have to create a servlet capable of responding to these requests. There are various tutorials on how to create a servlet.
Here is a link to a youtube video I fall back on when I forget how to do servlets: http://www.youtube.com/watch?v=EOkN5IPoJVs
In the video, he just uses straight up javascript; so you're php code is going to be doing what the javascript did in the video (item 1 on my list).
The video uses an older version of eclipse (I think ganymede), but it is pretty close to the same process in the newest version of eclipse.
Just to be blunt, this isn't something you're going to be able to figure out and make work properly. You've probably got at least a day to a weeks worth of learning here depending on your experience and aptitude; and this will only get you something basic. The servlet you make won't be secure, it won't have user authentication...my point is don't take anything for granted.

News Articles: Write to server disk without PHP?

I'm looking into a small project just now where we have a need for a very very basic news article system. Ideally, this is a simple XML file that will be written to with some news, and then parsed to display on the homepage. This file is on the server, of course.
My question is how to allow a client browser to write to this XML file, given that the server will not have PHP enabled?
I know of TiddlyWiki which uses a .JAR file to allow the writes, but are there any other methods I should try?
Since FTP seems to be enabled/supported, your best bet is to create an applet which does the job. FTP connectivity can fairly simple be done by Apache Commons Net FTPClient. Your only problem is that the FTP connection details needs to be embedded in the applet somehow and that anyone with bad intent can extract it from the applet's source code since applets are downloaded into the client machine.
Without some serverside code, you will not be able to write files to the server.
You need a "PHP/Java/FTP-Server/something else"-backend serverprocess to take the content and write it to a file.
Apache supports HTTP PUT, and some browsers support it in XMLHttpRequest. So long as you are willing to limit editors to browsers that support it, you could use that without installing additional software on the server or using a plugin on the client.
FTP would definitely work, depending on how well the user doing the updates is familiar with it.
If the upload solution needs to be browser-based, you could perhaps run an FTP applet and have the user remember the connection details/password.

Java - XMPP - I need some document or tutorial for it

i found XMPP on google (i need create a application IM look like Yahoo or Live or Pidgin), i need write XMPP Server and Client but i don't know how to write it?
because of it, it need some document or tutorial help me write server and client interactive with my database.
Thank you
Best Regards!
Either you can write your own or use the already proven open source libraries ready to be used. Look this post Good XMPP Java Libraries for server side?
If you are looking for tutorials, articles etc then go to xmpp.org or go to this post Good tutorials on XMPP?
You can also try writing server components with Whack framework. I've blog about using Whack here (part1, part2, part3).

Categories

Resources