Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Static files deployment with changing jboss config files

 
bala kam
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,

My issue is on deploying static files in JBoss 4.

I have a folder (external to JBoss) which will have all static files (html, swf, etc). I have deployed a servlet in deploy folder which need invoke a html file in that folder (I cannot read that file as stream, as that folder contains 100s of files which are accessible internally).

I have modified jboss-service.xml making that external folder as a war folder but our Architect suggests not to modify any jboss config files.

Please help me how to configure the external static files without changing any jboss config files. Is there any docBase I can set in any file within my application context.

Thanks in advance.

Regards
Bala
 
Rob Spoor
Sheriff
Pie
Posts: 20495
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to our JBoss forum.
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
bala kam wrote:Please help me how to configure the external static files without changing any jboss config files.

How do you expect JBoss AS to find an external directory if you cannot modify any of the configuration files to look there? Why do you think that the configuration files are text files, and not binary? They were set up that way so that you can modify them.
 
bala kam
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Peter Johnson wrote:
bala kam wrote:Please help me how to configure the external static files without changing any jboss config files.

How do you expect JBoss AS to find an external directory if you cannot modify any of the configuration files to look there? Why do you think that the configuration files are text files, and not binary? They were set up that way so that you can modify them.


Atleast if I deploy a servlet in deploy and is it possible set the parameter in web.xml or jboss-web.xml and refer to that static location. Is this possible.
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, neither web.xml nor jboss-web.xml contain such a setting. By the way, docs/dtd/jboss-web_5_0.dtd contains descriptions of all the settings in jboss-web.xml.

You could write a servlet that provides access to an external directory and send all requests for static data to that servlet.
 
bala kam
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Peter Johnson wrote:No, neither web.xml nor jboss-web.xml contain such a setting. By the way, docs/dtd/jboss-web_5_0.dtd contains descriptions of all the settings in jboss-web.xml.

You could write a servlet that provides access to an external directory and send all requests for static data to that servlet.


Thank you for your reply. Can you please help me with code of accessing external directory static files via Servlet. Would appreciate your help.
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here are some hints/suggestions:

1) Route all requests for static/* to your servlet

2) Place the relative file name in the URL and have the servlet extract it. Example: http://localhost:8080/myapp/static/docs/instr.pdf yields the relative directory docs/instr.pdf

3) Use a context-param to set the external directory base location

4) The servlet will have to understand the various file types that it will serve and set the content type properly. For example, for the file in item 2 above you would use:

response.setContentType("application/pdf");

5) Have the servlet open the file and send it to the response buffer. You might have to mess with the max buffer size (I have only done this for smaller files).
 
bala kam
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sure will do. Thank you so much for your help and response.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic