aspose file tools*
The moose likes Servlets and the fly likes Java Dynamic Servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Java Dynamic Servlet" Watch "Java Dynamic Servlet" New topic
Author

Java Dynamic Servlet

Carsten Rasmussen
Ranch Hand

Joined: Sep 22, 2009
Posts: 65
Well.. i got really good help on my last topic so here we go again.
I have searched the whole internet for a servlet like the one below who dynamic reads the file spitting out new content all the time.
Can anyone help on this one.

-- readfile.java



A shame you cant give eachother points cuz i would give 1000p for this one.
In my research i discovered that there are many ways of doing this function like.
If i just could repeat the function with delay or not without overload.



But i never managed to do it in anyway
your regards: Carsten Rasmussen
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

I'm not sure I understand the question. What is it you are trying to do?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Carsten Rasmussen
Ranch Hand

Joined: Sep 22, 2009
Posts: 65
I want to dynamic read a txt file and get new data all the time from the file.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42276
    
  64
So ... a request comes in, and the response consists of the contents of the file? At a quick glance, the servlet seems to do that. Which difficulty are you encountering? And what does the Thread.sleep code block have to do with it?


Ping & DNS - my free Android networking tools app
Carsten Rasmussen
Ranch Hand

Joined: Sep 22, 2009
Posts: 65
I want to read data.txt constantly like reading chat-data

Could be a way of delaying and do the function again over and over.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

So you want one request to generate n responses? That's not how HTTP works.

If its chat behavior you want you will need to use soemthing other than HTTP, which means an applet in the client, or AJAX to send multiple requests in the background.
Carsten Rasmussen
Ranch Hand

Joined: Sep 22, 2009
Posts: 65
I figured it out and now im gonna show it.

readfile.java


And the index.jsp with ajax.

Carsten Rasmussen
Ranch Hand

Joined: Sep 22, 2009
Posts: 65
May i add this for us Danish ( dk ) poeple
Instead of:

Do this:

In the readfile.java above.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java Dynamic Servlet