Jump to content
xisto Community
Sign in to follow this  
Inspiron

Writing & Reading Files With Jsp How to do it?

Recommended Posts

I've a project on creating a Movie online booking website that is powered with JSP.Now I'm trying to write and read from the file I wrote, but didn't know how.Can anyone with such expertise please teach me.. It has to be done with JSP.Thanks in advance..

Share this post


Link to post
Share on other sites

I've a project on creating a Movie online booking website that is powered with JSP.Now I'm trying to write and read from the file I wrote, but didn't know how.
Can anyone with such expertise please teach me.. It has to be done with JSP.

Thanks in advance..


Since you are coding jsp, I am assuming you have java programming knowledge. To read a file, you need java io package to be imported. So, here goes the import page directive at top of your jsp.

<%@page import="java.io.*"%>


Now, you have to create input stream using the file. Assuming the file is in the class path, you can get the stream by

java.net.URL url =config.getServletContext().getResource("yourfile.txt");BufferedReader buffreader =new BufferedReader(new InputStreamReader(url.openStream()));


Rest of the things are same as reading from a BufferedReader in java. Make sure that the java code in jsp is inside <% and %> tags.

Share this post


Link to post
Share on other sites
read from html text fields and write to a file using jspWriting & Reading Files With Jsp

I have to write a program that contains two text fields in a html page... Afterclicking on submit button those words should go and store in a file... How is that possible..Can any1 Please help me on this..

-question by sharma

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.