How to read web.xml parameters from GWT

459 views
Skip to first unread message

MickeyMiner

unread,
May 31, 2010, 4:53:37 AM5/31/10
to Google Web Toolkit
Hi,

How do I read parameters stored in /WEB-INF/web.xml from my
GreetingServiceImpl class?

After I insert following snipplet int web.xml:

<init-param>
<param-name>dbHost</param-name>
<param-value>192.168.120.120</param-value>
</init-param>
<init-param>
<param-name>dbName</param-name>
<param-value>my_database</param-value>
</init-param>

Is anything like this possible:

public class GreetingServiceImpl extends RemoteServiceServlet
implements GreetingService {
public String greetServer(String input) throws
IllegalArgumentException {
Series<Parameter> parameters = getContext().getParameters();
String strHost = parameters.getFirstValue("dbHost");
String strName = parameters.getFirstValue("dbName");
return "The target database is " + strName + "@" + strHost;
}
}


Thanx for your help and cheers!

mm

Manuel Carrasco Moñino

unread,
Jun 3, 2010, 2:38:48 AM6/3/10
to google-we...@googlegroups.com
You must override the init method:

public class GreetingServiceImpl extends RemoteServiceServlet
implements GreetingService {

private String strHost;
public void init(ServletConfig config) throws ServletException {
super.init(config);
String strHost = config.getServletContext().getInitParameter("dbHost");
}
}

-Manolo

> --
> You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
> To post to this group, send email to google-we...@googlegroups.com.
> To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
>
>

Reply all
Reply to author
Forward
0 new messages