SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Apr 2006
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help needed in file handling

    Hi,

    I need to read the contents of a .csv file (which should be uploaded by the user) and need to manipulate the file..

    Anyone's idea on this is appreciated

  2. #2
    SitePoint Wizard silver trophy rushiku's Avatar
    Join Date
    Dec 2003
    Location
    A van down by the river
    Posts
    2,056
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    You'll need:
    - a file upload page that has a form with an input type=file
    - the form will submit to your file upload servlet
    - the servlet will store the file on the server and pass the path on to your file manipulation class

  3. #3
    SitePoint Evangelist borna's Avatar
    Join Date
    Jun 2006
    Location
    Iran, Tehran
    Posts
    475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ..need to rad the contents of a .csv file ...
    Maybe the difficulty is at here,
    You may use the following code:
    Code:
    import java.util.*;
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    
    public class ShowForm extends HttpServlet{
        public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{
            response.setContentType("text/html");
            PrintWriter out =response.getWriter();
            
            ServletInputStream sis=request.getInputStream();
            for(int i=sis.read();i!=-1;i=sis.read())
                out.print((char)i);             
        }
        
        public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{
                doPost(request,response);            
            }
        
            
    }
    -1/2=999?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •