iVela
iVela

Reputation: 1201

How to know if my application is running over a JBoss server?

I am developing a GWT application.

And I would like to know if I am running over a Jboss instance or over a Jetty instance.

This is because if I am running over Jetty it means that I am running the dev mode and I need to redirect to MyModule.html?codeserver... but if I am running over Jboss I need to redirect to MyModule.html

But I can't figure how can I know if I am running over Jetty or over Jboss.

Upvotes: 1

Views: 2952

Answers (4)

koma
koma

Reputation: 6566

If you just want to know wether you are running production or development mode, then try

GWT.isProdMode();

Only works client-side of course.

Upvotes: 1

rickz
rickz

Reputation: 4474

In a JSP,

Server is <%= application.getServerInfo()%>

or use

Server is ${pageContext.servletContext.serverInfo}

in a Servlet,

String server = getServletContext().getServerInfo();

Upvotes: 0

Tyler Treat
Tyler Treat

Reputation: 14998

There's not really any simple way to determine what application server you're running on (to my knowledge). You could check some system properties to determine this.

JBoss:

jboss.server.name

Jetty:

jetty.home

Although I do not encourage having logic determined by your environment as Vikdor mentions in his answer. His suggestion would be a better approach.

Upvotes: 0

Vikdor
Vikdor

Reputation: 24124

You should not try to find out the webserver on which your application is running, in your application code. Instead you can have a discriminating parameter set in the context of your application with different values for different servers.

E.g.

For JBoss, the server.xml can contain a parameter in the context definition as follows:

<Context ...>
    ...
    <Parameter name="applicationStage" value="prod" />
    ...
</Context>

and for Jetty, the same context parameter would go into its jetty.xml but the value as "devo".

Upvotes: 2

Related Questions