Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Modify the processRequest() method in SimpleWebServer to use the preceding file storage and logging code

  1. #1
    Junior Member
    Join Date
    Oct 2019
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Modify the processRequest() method in SimpleWebServer to use the preceding file storage and logging code

    i am facing a hard time with this question ,is there anyone can help me to solve it ?
    HTTP supports a mechanism that allows users to upload files in addition to retrieving
    them through a PUT command.


    c. Consider the following code, which allows for text file storage and logging functionality:

    public void storeFile(BufferedReader br,
    OutputStreamWriter osw,
    String pathname) throws Exception {
    FileWriter fw = null;
    try {
    fw = new FileWriter (pathname);
    String s = br.readLine();
    while (s != null) {
    fw.write (s);
    s = br.readLine();
    }
    fw.close();
    osw.write ("HTTP/1.0 201 Created");
    }
    catch (Exception e) {
    osw.write ("HTTP/1.0 500 Internal Server Error");
    }
    }
    public void logEntry(String filename,String record) {
    FileWriter fw = new FileWriter (filename, true);
    fw.write (getTimestamp() + " " + record);
    fw.close();
    }
    public String getTimestamp() {
    return (new Date()).toString();
    }


    Modify the processRequest() method in SimpleWebServer to use the preceding file storage and logging code

    d. Run your web server and mount an attack that defaces the index.html home page

    how can i run the code and Modify the processRequest()???
    or
    given me instruction to solve it because i do not know from where i should start
    Last edited by awtarralhooob; October 28th, 2019 at 01:14 AM.

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Modify the processRequest() method in SimpleWebServer to use the preceding file storage and logging code

    Please edit your post and wrap your code with code tags:

    [code]
    **YOUR CODE GOES HERE**
    [/code]

    to get highlighting and preserve formatting.

    Modify the processRequest() method
    Where is the code for that?
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Oct 2019
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Modify the processRequest() method in SimpleWebServer to use the preceding file storage and logging code

    .

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Modify the processRequest() method in SimpleWebServer to use the preceding file storage and logging code

    ?
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. want to modify code that converts binary code to decimal numbers
    By noblegas in forum What's Wrong With My Code?
    Replies: 12
    Last Post: August 29th, 2014, 05:30 PM
  2. Replies: 3
    Last Post: May 8th, 2014, 06:25 AM
  3. Replies: 1
    Last Post: February 12th, 2012, 01:01 AM
  4. Logging excel file using log4j.properties
    By sneha343 in forum Java Theory & Questions
    Replies: 1
    Last Post: December 6th, 2011, 10:03 AM
  5. Problems with File Reader (Strings and 2D Array Storage)
    By K0209 in forum File I/O & Other I/O Streams
    Replies: 44
    Last Post: January 12th, 2010, 10:48 AM