[Logo]
Forums Register Login
Application client, glassfish server, file upload
HI,

Could someone point me in the right direction please...i'm new to java ee and already my head is spinning around trying to comprehend ideas like injection and dependencies and I dont have a clue what annotations I should be using... etc etc etc. I do know a little about java, though, and I have written a client application already, but now I want to simply upload some text files (in the future it will be dat files) to a server. I would prefer to do this with java ee and glassfish so I can begin to get my head around it all. From what I have read and understood, I think I should be creating an Enterprise Java Bean??? Is this correct? I am using Netbeans IDE if you want to go into detail!!! Cheers! KWB
Oh, I should clarify...I want to upload the files using the client I have already created e.g. user clicks an upload button...
Welcome to the Ranch

Why are you mentioning the names of products? Start by thinking what you are planning to do, not what tools to do it with. Otherwise it is like wanting to make a table and asking do you need a brace and bit. The right question would be to ask how do you make tables. And in computing, you doubtless know already, there are usually multiple correct answers.

Moving to our JavaEE forum.
oh cmon dude, how does that help? I need some direction...I would like to upload files to a server and I want to use java ee...plenty of tutorials etc doing it from a web application, but nothing on doing it from an application client...
 

karl waber wrote:plenty of tutorials etc doing it from a web application, but nothing on doing it from an application client...



I don't understand that. To upload a file, the thing at the client side has to make the contents of the file into a POST request and send it to the thing at the server side, which will deal with the upload as it sees fit. So both things have to cooperate.

When I used to do that, back when I was working, you'd use the code in Apache FileUpload to handle the POST request. Perhaps that's what you saw in some of those tutorials. If you did, then the assumption was that something, most likely a browser, was sending the POST request, so there was nothing to say about that. Anyway JEE has advanced considerably since I used it and it's possible that it now includes features to handle a file upload, which is why I'm not going to say any more than what I already said about the server side.
hey thanks, yeah, I've seen examples of a browser/post method, but nothing using an application client. On the server side, I think it would have to be an EJB, but I am far from certain. Maybe a servlet??? but I think you would use this in a web application (i need application client, no browser).

oh yeah...i have also seen some examples of an application client and an ejb - both of them implementing a 'remote' interface...i think this is how they are able to talk to each other...
 

karl waber wrote:but I think you would use this in a web application (i need application client, no browser).



I get the impression that you think you can just write some client-side code to do a file upload and then you're done. But that's not the case. You can't upload a file to a server unless you've got some software running there which is prepared to accept that file upload. And that software is by definition a web app.

As for the application client, instead of a browser, you could certainly write some client-side software to send the POST request to the web app. But you do need a web app.
As for how to do a file upload in JEE these days, I googled for jee file upload. And yeah, the way I used to do it is now obsolete. This part of the JEE tutorial tells you how to do it now.
what i mean by web app is using a browser and html, rather than using an application client
to me web app = browser + html + http
 

karl waber wrote:what i mean by web app is using a browser and html, rather than using an application client



Okay, that's the source of the confusion. A web app runs on the server side.
 

Paul Clapham wrote:

karl waber wrote:but I think you would use this in a web application (i need application client, no browser).



I get the impression that you think you can just write some client-side code to do a file upload and then you're done. But that's not the case. You can't upload a file to a server unless you've got some software running there which is prepared to accept that file upload. And that software is by definition a web app.

As for the application client, instead of a browser, you could certainly write some client-side software to send the POST request to the web app. But you do need a web app.




This is what I am asking about...I did mention an EJB, but I am not sure if this is the right way to go...if someone can clarify that, then this is what I have to research...
 

Paul Clapham wrote:As for how to do a file upload in JEE these days, I googled for jee file upload. And yeah, the way I used to do it is now obsolete. This part of the JEE tutorial tells you how to do it now.




this uses java ee servlet which I think, implies the use of a browser and http on the client side. I need to do it from an application client I have already written...unless there is some hybrid form - an application client using http
 

karl waber wrote:this uses java ee servlet which I think, implies the use of a browser and http on the client side.



Not at all. It just implies something sending an HTTP request. That could be a browser and often is, but it can be any code (including code written by you) which sends HTTP requests.
 

Paul Clapham wrote:

karl waber wrote:this uses java ee servlet which I think, implies the use of a browser and http on the client side.



Not at all. It just implies something sending an HTTP request. That could be a browser and often is, but it can be any code (including code written by you) which sends HTTP requests.



aha...you learn something everyday! OK, so I guess this is one way of doing it....what I have read about http is that for a few files, it might be ok, but if the number of files would increase over time, http might be too slow??? so now i'm just wondering if there is another way that is more efficient, and allows for future demand...so EJB? TCP/IP?
 

karl waber wrote:OK, so I guess this is one way of doing it....what I have read about http is that for a few files, it might be ok, but if the number of files would increase over time, http might be too slow??? so now i'm just wondering if there is another way that is more efficient, and allows for future demand...so EJB? TCP/IP?



It would be a good idea to go back to the place which suggested that HTTP might be too slow and read the next part, which suggests alternatives. If it doesn't make any suggestions then just disregard that "advice". People who make allegations of "too slow" without suggesting alternatives aren't worth listening to. In other words, don't base your design on rumours which you read somewhere, base your design on what actually happens in real life.

As for the acronyms you mention there: An EJB is a software component, part of... actually why don't I just refer you to the Wikipedia article: Enterprise JavaBeans. You'll notice it doesn't mention file transfer anywhere. And TCP/IP is just the low-level protocol for how almost everything gets transmitted around the web. HTTP is a higher-level protocol which runs on top of that.

Another way of uploading files is FTP, but you won't be doing any programming for that. You just install an FTP server and run an FTP client to send the files. As I think I said earlier, Java EE is entirely predicated on the idea that you're going to be communicating to the server via HTTP.
I mention TCP/IP because I have read some things about websockets, which use tcp/ip...and maybe i could use this. But I am still very unsure about what the architecture of the whole system would look like (this is why i refer to EJB etc....). There are so many possibilities that I dont know where to start. I'm hoping someone can shed some light on how this architecture would look, then I can go research the finer details...
There aren't really a lot of possibilities. If you want to write a web app which does file uploads, I already pointed you to a tutorial which showed how to do it. That's what you should do. Right now, though, you're like an architect who wants to build an apartment building but is confused by concepts like "concrete" and "electricity". Really, you just have a whole lot of terminology which you don't understand so you have no way of determining whether any of the terms are meaningful to you. But unfortunately it isn't the place of an online forum for somebody to educate you about those things -- for example the Wikipedia article about TCP/IP is about 5 pages long so expecting somebody to tell you all about TCP/IP on a forum, it just isn't going to happen.

So I'd suggest you just get started with that tutorial. It's going to be a struggle to get it working because there's a lot of other stuff that you'll find you don't understand, but working your way through is one way of learning that other stuff.

This thread has been viewed 608 times.

All times above are in ranch (not your local) time.
The current ranch time is
Dec 16, 2018 04:03:56.