Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to use dynamic file as welcome-file-list in web.xml  RSS feed

 
vinutha
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have configured my web.xml file as this,

<web-app>
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.xhtml</param-value>
</context-param>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>login.jsf</welcome-file>
</welcome-file-list>
</web-app>

and my login.xhtml file as this,
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:c="http://java.sun.com/jstl/core"
xmlns:f="http://java.sun.com/jsf/core">
<body>
<f:view>
<h:form>
UserName:<h:inputText id="userName"
value="#{bean.userName}" rendered="true"
required="true"/>
Password:<h:inputText id="password"
value="#{bean.password}" rendered="true"
required="true"/>
<h:commandButton id="submit" value="Submit" action="#{bean.authenticate}" />

</h:form>
</f:view>
</body>
</html>


but when i deploy this using tomcat and try to put url as this,
http://localhost:8080/project

Its not identifying welcome file from web.xml
I am getting error like this,
The requested resource (/project/) is not available.
 
vinutha
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to resolve this,

Thanks,
Vinutha.
 
Andres Quinones
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by vinutha ml:
I have configured my web.xml file as this,

<web-app>
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.xhtml</param-value>
</context-param>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>login.jsf</welcome-file>
</welcome-file-list>
</web-app>

and my login.xhtml file as this,
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:c="http://java.sun.com/jstl/core"
xmlns:f="http://java.sun.com/jsf/core">
<body>
<f:view>
<h:form>
UserName:<h:inputText id="userName"
value="#{bean.userName}" rendered="true"
required="true"/>
Password:<h:inputText id="password"
value="#{bean.password}" rendered="true"
required="true"/>
<h:commandButton id="submit" value="Submit" action="#{bean.authenticate}" />

</h:form>
</f:view>
</body>
</html>


but when i deploy this using tomcat and try to put url as this,
http://localhost:8080/project

Its not identifying welcome file from web.xml
I am getting error like this,
The requested resource (/project/) is not available.


Vinutha the problem is that the file login.jsf doesn�t exist. The solution to your problem is to create a login.jsp an the only thing you have to do is to put <jsp:forward page="login.jsf"/> and change your web.xml with this <welcome-file-list>
<welcome-file>login.jsp</welcome-file>
</welcome-file-list>
I hope this help.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!