This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes JBoss/WildFly and the fly likes Static files deployment with changing jboss config files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "Static files deployment with changing jboss config files" Watch "Static files deployment with changing jboss config files" New topic
Author

Static files deployment with changing jboss config files

bala kam
Greenhorn

Joined: Jan 27, 2009
Posts: 6
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

Joined: Oct 27, 2005
Posts: 19684
    
  20

Moving to our JBoss forum.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5823
    
    7

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

Joined: Jan 27, 2009
Posts: 6
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

Joined: May 14, 2008
Posts: 5823
    
    7

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

Joined: Jan 27, 2009
Posts: 6
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

Joined: May 14, 2008
Posts: 5823
    
    7

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

Joined: Jan 27, 2009
Posts: 6
Sure will do. Thank you so much for your help and response.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Static files deployment with changing jboss config files