web.xml

Web.xml: Are url-pattern tags relative to each other?

<servlet-mapping> <servlet-name>myName</servlet-name> <url-pattern>/aName</url-pattern> </servlet-mapping> <security-constraint> <web-resource-collection> ... <url-pattern> /* </url-pattern> </web-res...

in a J2EE application when does a listener get called?

I have a J2EE app and it has a listener in web.xml. Listener contains a method called contextInitialized I want to know when does contextInitialized actually get called? From my reading I understand that it gets called when deploying the application. Can there be situations/scenario's where it could be called after the application h...

url-pattern and wildcards

While configuring the security constraints for a web-module's roles in J2EE application I'm having the following problem: Application: Giving a servlet named customersServlet, which receives two parameters in the URL: A string representing an operation (INS, UPD, DLT and DSP). An identification number to identify a customer on which ...

What are the possible values of load_on_startup in a servlet entry on web.xml?

Obviously, load_on_startup value of 0 means don't, and 1 means do. But what does a value of 2 mean? EDIT: Obviously, I shouldn't assume things before I check them. A value of 0 still means load on startup. Thanks stacker. The servlet specification is surprisingly hard to reach. (Here's where I saw 2 as a possible value). ...

How to block a IP address using web.xml ?

How can I block a ip address with some configuration on web.xml? Do I need a filter? How can I implement one? ...

Web Form based login in Java

How can I block access to the site if a user is not logged in? Under web.xml > Security I checked Form authentication then I selected Login and Error page, but I don't know how to block the access and redirect the user to the login page. Do I need a filter? If so, how can I get the login url I specified? And how should I call the vali...

What is resource-ref in web.xml used for?

Hi everyone, I'm just wondering when/why you would define a resource-ref element in your web.xml file? I would have thought that it would be defined in your web/app server using JNDI and then look up the JNDI reference in your Java code? The resource-ref definition seems a bit redundant to me and I can't think of when it might be usef...

Using properties in web.xml

Hi, I would like to control the settings in web.xml and using different once for different environments. Is it possible to use a property, from a property file on classpath, in web.xml? Something like this: <context-param> <param-name>myparam</param-name> <param-value>classpath:mypropertyfile.properties['myproperty']</param-value...

How can I catch all errors to same page from web.xml?

I tried to use <error-page> <exception-type>java.lang.Exception</exception-type> <location>/errors/error.jsp</location> </error-page> but i dosen't catch 404 errors. How can I catch also 404 etc. errors to that same page ? I want to catch ALL error codes to same error page jsp. ...

JAVA: how to load database url from web.xml?

I'm using persistence API and want to load jdbc URL from web.xml. URL should be a context parameter of servlet. I can't find how to construct EntityManagerFactory not using persistence.xml. May be I should create PersistenceUnit in servlet and set some parameters? Can you give me some short example? Thank you ...

ETag in Spring (ShallowEtagHeaderFilter)

Hi guys, I've followed http://static.springsource.org/spring/docs/3.0.2.RELEASE/spring-framework-reference/html/mvc.html#mvc-etag and put ShallowEtagHeaderFilter in my web.xml like this: <filter> <filter-name>etagFilter</filter-name> <filter-class>org.springframework.web.filter.ShallowEtagHeaderFilter</filter-class> </filter> ...

JSF Facelets: Sometimes I see the URL is .jsf and sometimes .xhtml. Why?

Been try to learn JSF, and sometimes I see the URL is .jsf and sometimes is .xhtml. Can sometimes fill my knowledge, please? When I create a JSF using Facelet, the file extension is .xhtml, so where does .jsf URL extension come from? ...

JAVA: Can't get context parameters in Filter

Hello, I have a filter and parameters in web.xml web.xml is like this: <filter> <description> </description> <display-name>AllClassFilter</display-name> <filter-name>AllClassFilter</filter-name> <filter-class>com.datval.homework.AllClassFilter</filter-class> <init-param> <param-name>DB_URL</param-nam...

How to define a url not found servlet mapping in web.xml?

Hi, I have a web app, I want to define my index.jsp file to be shown when the entered url is like: www.mysite.com www.mysite.com/ www.mysite.com/index.jsp but if any other url is entered, like: wwww.mysite.com/g I want a particular servlet to handle the request. In my web.xml file, I am doing this: <servlet> <servlet-name>Ser...

Configuring web.xml for webservices and servlet.

Hi, I am new to Restlets. Trying to configure the web.xml (on JBoss). I have 2 entries, one for a servlet (got nothing to do with webservices) other for webservices, using Restlet. Here are the entries.. <servlet> <servlet-name>AuthenticationServlet</servlet-name> <servlet-class>com.safeid.web.server.api.servlet.AuthenticationServ...

Jersey JAX-RS on Glassfish 3.0.1: Can I have an empty webapp element in my web.xml?

My understanding is that glassfish 3 is JEE6 compliant and jax-rs-aware, and that consequently I do not have to include the jersey servlet container and mapping in my web.xml file. Here's what I was hoping my web.xml could look like <webapp> </webapp> That doesn't work though, as I get 404's when I try to hit my jax-rs path-anotated ...

Jsf library with web.xml

Jsf library (that is included in WEB-INF/lib) might contain its own faces-config.xml file. Is it possible for such a library to include also its own web.xml file? ...

Tomcat FORM authentication - login form not coming up as https

This is driving me nuts. I'm using Tomcat 6, declaritive authentication, form based. No framework involved. Everything works ok - some pages authenticated, some not, some use https, some http. Everything as I want it. EXCEPT... I want the login page to always use https. The login page comes up nicely as https if: a) I go to it directl...

One Java EE web application with two auth-methods

Hi, I have a web-app that authenticates against a JDBC Realm. In the web.xml file I can use BASIC authentication or a custom form: <auth-method>BASIC</auth-method> <realm-name>JDBCRealm</realm-name> or <auth-method>FORM</auth-method> <form-login-config> <form-login-page>/login.html</form-login-page> <form-error-page>/error...

Issue with JSF ViewExpiredException and multiple error-page tag definitions in web.xml

I'm working on a JSF web application in which I need to bring up a "Session Expired" page if the view expires, but a general technical error page for all others. The application only goes to the technical error page when I trigger the exception. Here's the error-page definitions: <error-page> <exception-type>javax.faces.applicati...