If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

file I/O on clients computer using JSP??

Ok, I just started dipping into J2EE and of course have some questions. To make it short and sweet, I want to know if it is possible for a JSP page to gain any type of file access to the client's computer?

Yes i realize "on the browser" it is just HTML. I guess i should have worded my question better. Can the J2EE server somehow access the client's file system.. But it seems from your response this is not possible as i suspected. I thought of an applet like you mention. Correct me if I'm wrong, but can't a signed applet accepted by the client gain limited access to the client's file system? Either way, I'm looking for some way to write a simple text file to the client's computer. I would prefer to do it with some type of server-side technology rather than client-side because I don't want to have to rely on a client having a specific plugin. I guess I'm barking up the wrong tree because this if this was possible it would allow websites to place mallicious files on a client's computer. What other options do I have? Maybe have an automated email system that sends an email to the clieent with the file as an attachment?

EDIT: Nevermind, I just thought of a solution. I could generate the file and save it on the server, and then use JSP to dynamically create a page with a link to the file. I'm guessing I have unlimited acccess to the file system on the server-side? Correct?

I actually meant to write that i'm creating an XML file, not a simple text file (i'm a little out of it right now). So I cannot have any HTML or other stuff mixed in with it, therefore i need it to be a file. Anyways, it seems creating the file and then genrating a link for the client would be the best way. So I guess the last question I have is how do I go about dynamically creating the file on the server? Since J2EE is built on top of J2SE does this mean that I can simply use the file access methods that I would in a stand alone application? Or is it more complicated than that? Is it server specific? (i'm using Sun's Application Server by the way).

Let me theorize how I think I could do it and someone tell me if this is right.

I have a form that the user goes to. They fill out the info and hit the submit button. They are directed to a JSP page that pulls the information and places it inside a java bean, this bean is then passed to a class I made that creates the XML file on the server (using typical file access as i would in a stand alone app, specifically the java.io classes). The JSP page also provides a link to the newly created file allowing the user to download it.

It depends on your design of course but you don't have to create a file at all. You can create the xml doc in memory and stream that out to the browser either as the response to the form submission or as a link to a servlet on the form response page.