Really need help here..urgent!!

This is a discussion on "Really need help here..urgent!!" within the Other Programming Languages section. This forum, and the thread "Really need help here..urgent!! are both part of the Program Your Website category.


 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Program Your Website > Other Programming Languages

Notices




Reply
 
LinkBack Thread Tools
  #1  
Old Jun 27th, 2007, 05:15
New Member
Join Date: Jun 2007
Location: Makaysia
Age: 21
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Post Really need help here..urgent!!

Hello... i have a process where user want some data file(textfile.txt) from somewhere for example from D:\smart\445566.txt. After user have that file, user can choose whether he want save that file or display it as a text file. I have searched many times through web but didn't find any suitable example or solution..
So..anyone here can give me some idea or code example about this problem???
~i'm using JSP..
~i really really need help here..
~thanks...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

  #2  
Old Jun 27th, 2007, 06:37
Highly Reputable Member
Join Date: Apr 2007
Location: Willich, Germany
Age: 20
Posts: 593
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Really need help here..urgent!!

I have no clue about JSP but in PHP that's no problem: Download: zip the file dynamically and give the user the link. View: either just give the user a link to the file or, a much better solution, read the file with PHP and output it with some css formatting. I don't know if you have the possibility to use PHP, I hope this helps.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old Jun 27th, 2007, 07:13
New Member
Join Date: Jun 2007
Location: Makaysia
Age: 21
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Really need help here..urgent!!

thanks for the reply..
But i have to do it in JSP...
Hope anyone in here can give me some idea or example
~thanks...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4  
Old Sep 17th, 2007, 14:00
New Member
Join Date: Sep 2007
Location: Bristol
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Really need help here..urgent!!

The easy option would be just to supply a link to the file. Assuming it's just a text file, when the user clicks on the link, the browser should render the file contents on screen or pop up the download window.

If you want to display the file contents within your JSP page (a textarea for example) you'll need to do something server side with your JSP/Servlet code.

Somthing like this should do it:

Code: Select all
public static String getStringFromFile(String path)
    throws IOException {
        StringBuffer buff = new StringBuffer(5000);
        BufferedReader in = new BufferedReader(new FileReader(path));
        try {
            String line = null;
            while ((line = in.readLine()) != null) {
                buff.append(line).append('\n');
            }
        } catch (IOException ex) {
            log.error("Problem getting string from file", ex);
            throw ex;
        } finally {
            if (in != null) in.close();
        }
        return buff.toString();
    }
This method returns the contents of a file as a string that you can then display in your JSP page.

Hope this helps.

-Steve

Last edited by Aso; Jul 24th, 2008 at 11:54. Reason: Sig removed
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
jsp

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Need some urgent help....!!!! shevorne Web Page Design 9 Sep 30th, 2007 23:36
Urgent help please marie2007 PHP Forum 3 Sep 9th, 2007 22:44
XSL - urgent ai0912 Other Programming Languages 0 Nov 6th, 2006 13:35
urgent help req.. s_mazhar Graphics and 3D 5 Oct 31st, 2005 09:04


All times are GMT. The time now is 02:18.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42