Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Need Help reading files from a server  RSS feed

 
Marcelo Tataje
Ranch Hand
Posts: 64
Java Oracle Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everybody, I have a problem which I don't know how to start solving.

I'm creating an stand alone application that can be able to read files located in a server.

For instance, I have a web application in my linux server which has a Tomcat 6.0 (It has authentication as well)

So, for example, I want my stand-alone application to read a log file located in this route: /usr/share/tomcat6/logs/log.xml

The content parsing can be solved easily, but I wonder how to start making the connection, since the tomcat needs an user and password to connect and how can I give the route.

I'm not sure if I have to use HTTPConnection or just open an URLConnection.

If somebody could help me I'll be very grateful. Thank you in advance.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since that file is not in a publicly accessible directory, you can't get at it via HTTP from the outside. You need to write a servlet that is accessible from the outside - it can then stream the log file to the client.
 
Marcelo Tataje
Ranch Hand
Posts: 64
Java Oracle Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I thought there was a way to let my application retrieve the information from files stored in Tomcat Server. But if there's no choice, I will write the Servlet. Maybe a webservice can work.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I thought there was a way to let my application retrieve the information from files stored in Tomcat Server.

There may be, if the server is set up that way - could be by FTP, WebDAV, shared directory etc. But I would strongly advise against setting up a server so that it's possible to access its server installation directories from the outside by these means; that's a recipe for disaster.
 
Marcelo Tataje
Ranch Hand
Posts: 64
Java Oracle Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah, you're right, but I'm using log4j with an dailyrolling file appender that saves logs in xml in the /usr/share/tomcat6/logs directory of tomcat, I know there are many log4j viewers but I made a custom layout for xml files, far different from the default. That's why I created my own stand-alone log viewer, that can retrieve the xml file in the format I set up.
I wonder to know how can I get over this problem, if any suggestion, I'll be very grateful. Thanks for your reply.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!