You probably have to stop and then start the ServletHolder after changing
the init params, so that the changed params are noticed.
Don't stop/start the whole context as the defaultweb.xml and web.xml will
get run again and overwrite your changes.
Currently there is no way to write out a Jetty configuration file. Perhaps
you could do something with Jelly to replace the jetty configuration files?
Cisco have done an extension of the jetty config file to allow them to
be written out, but they have not open sourced that yet... but they may do
at some stage soon.
cheers
Proebster, Rainer wrote:
Hi,
is it possible to change the init-params of a Jetty-context during runtime?
And how do I do this programmatically (on the fly - without changing something
in an xml-file)?
And last, what is the recommended way to save a programmatically changed
configuration to a xml-file?
In my webdefault.xml I have something like this:
....
<servlet>
<servlet-name>JSP</servlet-name>
<servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
<init-param><param-name>keepgenerated</param-name><param-value>true</param-value></init-param>
<init-param><param-name>development</param-name><param-value>true</param-value></init-param>
<init-param><param-name>fork</param-name><param-value>true</param-value></init-param>
<init-param><param-name>reloading</param-name><param-value>true</param-value></init-param>
<init-param><param-name>checkInterval</param-name><param-value>60</param-value></init-param>
....
I tried to change this for one of my contexts like this:
public void setInitParam(String sParam, String sValue) throws Exception {
ServletHolder[] holder =
jtySrvConfig.getJspContext().getServletHandler().getServlets();
for (int i=0; i<holder.length; i++) {
if(holder[i].getName().equals("JSP")) {
System.out.println("before: "+holder[i].getInitParameters());
jtySrvConfig.getJspContext().stop();
holder[i].setInitParameter(sParam, sValue);
jtySrvConfig.getJspContext().start();
System.out.println("after: "+holder[i].getInitParameters());
ServletConfig config = holder[i].getServlet().getServletConfig();
System.out.println(config.getClass().getName());
Enumeration en = config.getInitParameterNames();
while(en.hasMoreElements()) {
String s = (String)en.nextElement();
System.out.println(s+": "+config.getInitParameter(s));
}
break;
}
}
}
But this doen't work!
Thank you for all help!!
Best wishes,
Rainer
-------------------------------------------------------
This SF.net email is sponsored by: Perforce Software.
Perforce is the Fast Software Configuration Management System offering
advanced branching capabilities and atomic changes on 50+ platforms.
Free Eval!
http://www.perforce.com/perforce/loadprog.html
_______________________________________________
Jetty-support mailing list
Jetty-support@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/jetty-support
-------------------------------------------------------
This SF.net email is sponsored by: Perforce Software.
Perforce is the Fast Software Configuration Management System offering
advanced branching capabilities and atomic changes on 50+ platforms.
Free Eval!
http://www.perforce.com/perforce/loadprog.html
_______________________________________________
Jetty-support mailing list
Jetty-support@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/jetty-support
Thread at a glance:
Previous Message by Date:
click to view message preview
Re: Changing port in runtime
Vid,
you can change the port using setPort at any time, but
it does not take effect until you call stop() and then start()
of the HttpListener that you are changing.
You can test this yourself by running jetty with JMX and
using the JMX agent view to change the port yourself at
runtime.
cheers
Sagar Saladi wrote:
Hi all,
Is there a way to reconfigure the port on which
Jetty server is running, in runtime.
For example, say, my web application is running on
Jetty at port 9080. In the web application, the user
is allowed to enter a port nomber, say, 9081. Now I
want to reconfigure Jetty to run on port 9081.
This all should be done automatically. I think I have
to dig into the source code of Jetty.
Please tell me if I can do this. Any help is
appreciated.
-------------------------------------------------------
This SF.net email is sponsored by: Perforce Software.
Perforce is the Fast Software Configuration Management System offering
advanced branching capabilities and atomic changes on 50+ platforms.
Free Eval! http://www.perforce.com/perforce/loadprog.html
_______________________________________________
Jetty-support mailing list
Jetty-support@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/jetty-support
Next Message by Date:
click to view message preview
Re: context reloadable
Tuan,
Jetty does not support auto reloadable context. This is because there are
sooo many different ways this can be implemented -servlet by servlet,
class by class, context by context - and many ways that it can be
triggered - update of directory, update of web.xml, update of any jar,
update of any file etc. etc.
However, if you know which of the above you want for yourself, then it
is pretty simple to add. Normally you just need to watch a file (eg web.xml)
and if it changes then do a stop() & start() on the context to get it to
reload and restart everything.
cheers
Tuan Nguyen wrote:
Hi ,
I am integrating exoplatform with jetty and it work very well. But I
cannot figure out how to set context reloadable = true so I can
redeploy the the portlet application (my portlet application is a
directory , not an war file) .
Thank you very much
Tuan Nguyen
-------------------------------------------------------
This SF.net email is sponsored by: Perforce Software.
Perforce is the Fast Software Configuration Management System offering
advanced branching capabilities and atomic changes on 50+ platforms.
Free Eval! http://www.perforce.com/perforce/loadprog.html
_______________________________________________
Jetty-support mailing list
Jetty-support@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/jetty-support
-------------------------------------------------------
This SF.net email is sponsored by: Perforce Software.
Perforce is the Fast Software Configuration Management System offering
advanced branching capabilities and atomic changes on 50+ platforms.
Free Eval! http://www.perforce.com/perforce/loadprog.html
_______________________________________________
Jetty-support mailing list
Jetty-support@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/jetty-support
Previous Message by Thread:
click to view message preview
resetting init-params with Jetty
Hi,
is it possible to change the init-params of a Jetty-context during runtime?
And how do I do this programmatically (on the fly - without changing something
in an xml-file)?
And last, what is the recommended way to save a programmatically changed
configuration to a xml-file?
In my webdefault.xml I have something like this:
...
<servlet>
<servlet-name>JSP</servlet-name>
<servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
<init-param><param-name>keepgenerated</param-name><param-value>true</param-value></init-param>
<init-param><param-name>development</param-name><param-value>true</param-value></init-param>
<init-param><param-name>fork</param-name><param-value>true</param-value></init-param>
<init-param><param-name>reloading</param-name><param-value>true</param-value></init-param>
<init-param><param-name>checkInterval</param-name><param-value>60</param-value></init-param>
...
I tried to change this for one of my contexts like this:
public void setInitParam(String sParam, String sValue) throws Exception {
ServletHolder[] holder =
jtySrvConfig.getJspContext().getServletHandler().getServlets();
for (int i=0; i<holder.length; i++) {
if(holder[i].getName().equals("JSP")) {
System.out.println("before: "+holder[i].getInitParameters());
jtySrvConfig.getJspContext().stop();
holder[i].setInitParameter(sParam, sValue);
jtySrvConfig.getJspContext().start();
System.out.println("after: "+holder[i].getInitParameters());
ServletConfig config = holder[i].getServlet().getServletConfig();
System.out.println(config.getClass().getName());
Enumeration en = config.getInitParameterNames();
while(en.hasMoreElements()) {
String s = (String)en.nextElement();
System.out.println(s+": "+config.getInitParameter(s));
}
break;
}
}
}
But this doen't work!
Thank you for all help!!
Best wishes,
Rainer
-------------------------------------------------------
This SF.net email is sponsored by: Perforce Software.
Perforce is the Fast Software Configuration Management System offering
advanced branching capabilities and atomic changes on 50+ platforms.
Free Eval! http://www.perforce.com/perforce/loadprog.html
_______________________________________________
Jetty-support mailing list
Jetty-support@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/jetty-support
Next Message by Thread:
click to view message preview
context reloadable
Hi ,
I am integrating exoplatform with jetty and it work very well. But I
cannot figure out how to set context reloadable = true so I can
redeploy the the portlet application (my portlet application is a
directory , not an war file) .
Thank you very much
Tuan Nguyen
-------------------------------------------------------
This SF.net email is sponsored by: Perforce Software.
Perforce is the Fast Software Configuration Management System offering
advanced branching capabilities and atomic changes on 50+ platforms.
Free Eval! http://www.perforce.com/perforce/loadprog.html
_______________________________________________
Jetty-support mailing list
Jetty-support@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/jetty-support