Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8987533
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:49:07+00:00 2026-06-15T21:49:07+00:00

I am writing an online text editor for school. I have been able to

  • 0

I am writing an online text editor for school. I have been able to save a file with a custom name, so that is not the problem. With an HTML form I have, it submits the text of the TextArea into a file specified by the user, then set the url to be blah.org/text.jsp?status=gen. Later in the code, I have the program write the file if the variable status == gen, otherwise do nothing. I am not able to create the file when I click submit, and I am thinking it has something to do with me getting the variable in the URL. Here is my code:

    /* Set the "user" variable to the "user" attribute assigned to the session */
String user = (String)session.getAttribute("user");
String status = request.getParameter("status");
    /* Get the name of the file */
String name = request.getParameter("name");
    /* Set the path of the file */
String path = "C:/userFiles/" + user + "/" + name + ".txt";
/* Get the text in a TextArea */
String value = request.getParameter("textArea");
    /* If there isn't a session, tell the user to Register/Log In */
if (null == session.getAttribute("user")) {
out.println("Please Register/Log-In to continue!");
    if (status == "gen") {
        try {
            FileOutputStream fos = new FileOutputStream(path);
            PrintWriter pw = new PrintWriter(fos);
            pw.println(value);
            pw.close();
            fos.close();
    }
    catch (Exception e) {
        out.println("<p>Exception Caught!");
    }
} else {
out.println("Error");
}
}

and the form:

<form name="form1" method="POST" action="text.jsp?status=gen">
<textarea cols="50" rows="30" name="textArea"></textarea>
<center>Name: <input type="text" name="name" value="Don't put a .ext"> <input type="submit" value="Save" class="button"></center>
other code here </form>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T21:49:08+00:00Added an answer on June 15, 2026 at 9:49 pm

    You’re comparing Strings with == instead of comparing them with .equals(). == compares the strings are the same object instance, not if they contain the same characters.

    Make sure to read the IO tutorial. Streams should always be closed in a finally block, or you should use the Java 7 try-with-resources construct.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am writing a online text editor application, and i need to save data
By blog-editor i mean text-editors that are used to write blogs online. Example would
I'm writing an online application where I save some texts to the database. There
Basically, I have a problem with a script that I'm developing. The problem is
I am writing a compiler program to read a text file. Some of the
I sometimes find myself writing text where part of the file is generated by
I am writing an MFC C++ application that has a Save As button for
I have a php file that I want to add an include path to
lets get straight to my problem, the code I have written here does not
I have a 100 GB text file, which is a BCP dump from a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.