Add to Google

Writing & Reading Files With Jsp - How to do it?

free web hosting
Open Discussion > CONTRIBUTE > Computers > Programming Languages > Java, Java Servlets, Java Script, & JSP

Writing & Reading Files With Jsp - How to do it?

Inspiron
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..

Reply

kvkv
QUOTE(Inspiron @ Feb 4 2006, 06:12 AM) *

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.

CODE
<%@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

CODE

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.

 

 

 


Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

Recent Queries:-
  1. jsp how to write a file - 2.02 hr back. (1)
  2. read jsp files - 3.10 hr back. (1)
  3. read a text file in jsp - 4.99 hr back. (1)
  4. java read file write backwards - 6.16 hr back. (1)
  5. how to read files from jsp - 6.48 hr back. (1)
  6. reading log file in jsp - 6.74 hr back. (1)
  7. read the file on jsp page - 10.20 hr back. (1)
  8. jsp write file - 10.85 hr back. (1)
  9. file reading in jsp - 11.48 hr back. (1)
  10. text from jsp file - 16.79 hr back. (1)
  11. jsp read url to html file - 22.83 hr back. (1)
  12. writing to a file from jsp - 26.68 hr back. (1)
  13. jsp read file - 21.79 hr back. (4)
  14. to read .jsp file - 27.94 hr back. (1)
Similar Topics

Keywords : writing, and, reading, files, jsp

  1. Jar Executable Files
    (3)
  2. Eclipse Exporting .jar Files
    Could not find main class. Program will exit. (5)
    I need help! I've been using eclipse for a while making little applets, and now I've
    decided to look at some tutorials on how to make simple applications. I've found a pretty good
    tutorial that tells you how to make a helloWorld app with swt and jFace, and also has an example
    file explorer that you can make. They both work perfectly from inside eclipse, but when I try and
    export either one into a .jar file, they don't work anymore. It comes up with a message saying
    "Could not find main class. Program will exit." In the little wizard it has for exp....
  3. What To Do With .java Files?
    (8)
    Ok, I "know" Java, but what now? What do you do with the .java files? (I'm interested in both
    java-applets and java-programs.) Thanks, Peroim.....
  4. Help Writing An Html Code (onclick Open Something)
    (5)
    hi, I am new in web development i want to make a page in which there are few buttons and on click
    of each button there is some hidden text field which becomes visible and user can enter the text he
    wish to in it. how can i ?....
  5. Running .java Or .class Files From Runtime
    (1)
    from an API and outputs the result to the API (like someAPI.submitResult(myResult), which checks the
    results against the sample values. The idea is that the student is able to click a browse button and
    locate their .java or .class file, which the GUI then launches. So my question is if I can launch
    this class as part of the GUI process so that the API actually is actually part of the GUI process.
    It's a bit backwards really - like launching the API first and then adding in the component that
    uses the API during runtime. But there is an advantage of doing it this w....
  6. Writing A Text File On Wen Host
    write to the text file on the webhost (1)
    Hi! i need to write a text file with applet on the wen host. It is like a guest book that the
    visitor enters his comments and the comments are stored in the text file. I found a website which
    presents a method to write text files to the visitor's computer but i need to write the text
    file to the webhost the applet is hosted. its like a log file or a guest book. I know there is a
    way and it can be done but i can't figure it out! Any help would be appreciated! Thanks!
    kvarnerexpress Topic title and description are VERY import to this forum. Edit to fit the quest....
  7. Deployment Problem: Disappearing Files?
    (1)
    Hi, I am attempting to deploy a web app. I compile it and make it a war. I restart tomcat and the
    war is distributed. I then go onto the internet and type in:
    http://localhost:8080/manager/deploy?path=/myapp a few different things have happened when I have
    typed in the same thing. The most prevelant error is: FAIL - Failed to deploy application at
    context path /myapp...is this error because of my build file or because of my web.xml file?? or
    neither? One time the stupid thing actually deployed. I went back and checked my directory and all
    my files were gone! The fold....
  8. Reading From A Text File
    (8)
    Reading from a text file whats up guys, got some more questions. we are starting to learn how to
    write and read strings to/from txt files. wel thats pretty easy, but how would i retrieve only the
    first 2 lines of the txt file, for example, if i wanted the first 2 lines, not any other, how would
    i do it: 12 90 12 6 -9 how would i go baout doin this. thnks ke....


    1. java read file write backwards, how to read files from jsp, reading log file in jsp, file reading in JSP, text from jsp file, writing a file in Jsp, how to read jsp file, jsp read file, jsp file read, read from a file in JSP, writing a file from jsp

      Looking for writing, and, reading, files, jsp






*SIMILAR VIDEOS*
Searching Video's for writing, and, reading, files, jsp

*MORE FROM TRAP17.COM*
advertisement



Writing & Reading Files With Jsp - How to do it?