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 8431595
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:53:50+00:00 2026-06-10T05:53:50+00:00

I have problem with my program in JSF on Google App Engine platform. I

  • 0

I have problem with my program in JSF on Google App Engine platform. I almost finished implement chat application in Java EE, when I read that class FileOutputStream isn’t supported by GAE.
By this class object I create file, to write inside it chat messages and by scirpt this file is loaded and refreshed on index.xhtml website.

I need help because I don’t know which class can I replace FileOutputStream to finish this application. I found example in Python so I know that this is possible, but how to implement it in Java?

I will be grateful for any help.

Below I paste piece of class ChatBean with FileOutputSream operations:

@Stateful
@ApplicationScoped
@ManagedBean(name="Chat")
public class ChatBean {

    private List<String> users = new ArrayList<String>();
    private String newUser;
    FileOutputStream chatHtmlBufferWriter;

    public ChatBean () throws IOException {
        ServletContext ctx = (ServletContext) FacesContext.getCurrentInstance().getExternalContext().getContext();
        String chatHtmlPath = ctx.getRealPath("/") + "chat";
        try {
            this.chatHtmlBufferWriter = new FileOutputStream(chatHtmlPath);  
            this.chatHtmlBufferWriter.write("Start chatu ąęć. <br />".getBytes("UTF-8"));
        } catch (IOException ex) {
            this.chatHtmlBufferWriter.close();
            throw ex;
        }

        users.add("Admin");
    }

    @PreDestroy
    public void closeFileBuffor() throws Exception {
        this.chatHtmlBufferWriter.close();
    }

    public String addMessage(String msg) throws IOException {
        this.chatHtmlBufferWriter.write(msg.getBytes("UTF-8"));    
        FacesContext.getCurrentInstance().getExternalContext().redirect("index.xhtml");
        return "index"; 
    } 
...
}

And script inside index.xhtml file:

<script src="http://code.jquery.com/jquery-latest.js"></script>
            <script>
                var currPos = 0;
                var loadChat = function() {
                    $("#chatForm\\:chatbox").load('chat');
                    currPos = $(".chat")[0].scrollHeight;
                    $(".chat").scrollTop(currPos);
                }
                var scrollChat = function() {
                    $("#chatForm\\:chatbox").load('chat');
                    $(".chat").scrollTop(currPos);
                }
                var currPos;

                $(document).ready(function() {
                    $("#chatForm\\:chatbox").load('chat', function(){
                        loadChat();
                    });
                    var refreshId = setInterval(function() {
                        scrollChat();
                    }, 1000);
                    $.ajaxSetup({ cache: false });                    
                    $("#chatForm\\:chatbox").scroll(function() {
                        currPos = $(".chat").scrollTop();
                    });
                });
            </script>
  • 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-10T05:53:52+00:00Added an answer on June 10, 2026 at 5:53 am

    Basically, you can’t directly write to the File System (although you can read).

    You will need to use one of the existing GAE storage APIs, such as the blobstore which has a File like API. Other options are detailed on the Storing Data page.

    However, I’m not sure you’re thinking about this correctly; you just want to create a GET method that returns the current messages and is called by your script. The messages will never be written to file at all. To begin with, you could just store the messages in memory. I suspect the tutorial you link to does the same.

    (UPDATE: I originally said FileOutputStream was in the whitelist, but I was looking at FilterOutputStream. Oops.)

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

Sidebar

Related Questions

I have problem with my Java program. How I read xml -file which has
i have the following problem. The 1st step is to implement a program, which
I'm using google app engine/python. And I have created a custom datatype and property.
well, almost everything is in the question, I have a problem with program which
This is my server code I have a problem because my program freeze and
Problem: Have made a small mail program which works perfectly on my developer pc
I have a problem with 2D transformation program I have the source code import
I have a problem with my iPhone program. I have imported a folder into
Basically i have a problem with this timer program I am trying to put
with my RCP program I have the problem that I want to have more

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.