Using a 'Welcome' file

Setting the starting page for a project is a simple matter, but I'm having some trouble trying to automatically forward to another page inside the framework.
My intention is to automatically redirect from 'index.jsp' to another page, purely for the purpose of establishing a session in which to store values. I've tried using the <jsp:forward page="/nextPage.faces"/>, but I'm receiving "page not available" errors from the server.
Is there a simpler way to accomplish this step using the IDE tools?
Thanks

No takers yet? Perhaps my original question was too vague. Let me explain my predicament. I've coded a page that includes a radiobutton list that contains some conditional code. The list defaults to option 1, but if the user selects option 2, the page reloads without rendering a certain control that becomes superfluous. I'm storing the selected value of the radiobutton list in a string property in my session bean and that is what I'm checking each time the page loads.
The problem is, the session hasn't been created on the very first time the page loads. When I click the radiobutton, the page resubmits and a session is generated. However, that's too late if I select the option 2. The unwanted component is still generated because there wasn't a property to check. Everything works great after the session is started, it's just the initial click that is the problem.
So that's why I'm looking for a way to get the session started out of the chute. Core jsf recommends using an index.jsp page as the start file with a <jsp:forward> tag that routes the user into the faces servlet. However, that requires a change to the web.xml file - and that kills the domain.xml file of the Sun App Server (An ugly story not related to this thread).
My question is, do I have to be a pro with the Sun App server's domain.xml file to do this, or does the JSC IDE provide some mechanism to start a session with the initial page load?

Similar Messages

  • After build, modified  welcome-file is reset (Creator 2)

    Is it possible to use different welcome-file in jsf
    WebProject (Creator 2 release)?
    <welcome-file-list>
    <welcome-file>faces/Page1.jsp</welcome-file>
    </welcome-file-list>
    <welcome-file-list>
    <welcome-file>JSCreator_index.jsp</welcome-file>
    </welcome-file-list>
    The start up page is modified if you change to other
    pages. Only the above two configurations are allowed.
    Any help is appreciated.

    thanks for the reply
    Currently, I use the property inside project.properties (under nbproject directory) for start up page.
    for example:
    client.urlPart=modified_startup.jsp
    However, it does not help with modifying the welcome-file in the web deployment file

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

    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.
    How to resolve this,
    Thanks,
    Vinutha

    This might help:
    http://forum.java.sun.com/thread.jspa?threadID=696586
    As well, you might have to change the servlet-mapping in your web.xml. The url-pattern, I think, needs to be .xhtml. Your login.jsf file in the welcome list will need to be renamed to login.xhtml.
    CowKing

  • Can I use servlet as my welcome file

    How can I use servlet as my welcome file? I know how to use jsp or html pages as my welcome file but that doesn't work for servlets. I modified my web.xml for making jsps and html as my welcome pages but that <welcome-file-list> tag is not working for servlets.

    This was a bug that occured in older Tomcat programs, not sure if it still occurs or not.
    Basically, when this happens, you have to have a physical file with the welcome file name. So you would have to create a file named index.do in each of your directories you wanted the welcome to work for. The index.do wouldn't have to actually do anything. It just had to exist. Then when the URL was used to create content, the servlet would be called to create that content.

  • How to chage the welcome file in web.xml using creator?

    Hi guys,
    I want to set the welcome file in web.xml to index.html but every time I run my project in creator, creator replaces index.html by faces/index.jsp. I need the index.html to check if the browser enables cookies & javascript and then I redirect to index.jsp. If I change the web.xml in a common editor, build the war-file with ant and deploy the project with tomcat, everything is fine. but how can I change it in creator?
    thanks in advance

    Sorry, that doesn't make much sense.
    The XML you gave is a configuration file for txt2xml utility. It doesn't represent the output format.
    Are you a user of this utility?

  • Help required in using same excel file as both Input and Output source

    Hello Programmers, Here I am trying to read, modify and write an excel file using JAVA, I have successfully employed Jakarta POI and read the file but the problem is that I can''t make changes in the same file and save it.
    I can't use the same file for "FileInputStream" and "FileOutputStream" I think this is causing major hurdle. Any kind of suggestion and help is truly appreciated and welcome. Thank you for your time. Here I am posting my code its a bit crude please pardon.
    * @(#)attempt4.java
    * attempt4
    * @author
    * @version 1.00 2008/3/26
    import java.io.*;
    import java.util.*;
    import org.apache.poi.poifs.filesystem.*;
    import org.apache.poi.hssf.usermodel.*;
    public class attempt4 {
    public static void main(String[] args) {
    try{
    File xlFile = new File("C:\\Drifter\\Study\\Krishnan\\Test.xls");
    FileInputStream readFile = new FileInputStream(xlFile);
    POIFSFileSystem fileSys = new POIFSFileSystem(readFile);
    HSSFWorkbook xlSheetBook = new HSSFWorkbook(fileSys);
    for(int i = 0; i < xlSheetBook.getNumberOfSheets(); i++) {
    HSSFSheet sheetNow = xlSheetBook.getSheetAt(i);
    System.out.println("\n Now Opening Sheet Number" + (i+1));
    if(sheetNow.getPhysicalNumberOfRows() > 0) {
    int numOfRows = sheetNow.getLastRowNum();
    int numOfColumns = 0;
    for(int cols = 0; cols < numOfRows; cols++) {
    HSSFRow rowNow = sheetNow.getRow(cols);
    if(rowNow != null) {
    if(numOfColumns < sheetNow.getRow(cols).getLastCellNum()) {
    numOfColumns = sheetNow.getRow(cols).getLastCellNum();
    System.out.println("\n There are " + (numOfRows+1) + " Number of Rows");
    System.out.println("\n There are " + numOfColumns + " Number of Columns");
    for(int j = 0; j < numOfColumns; j++) {
    float colTotal = 0;
    int numOfNumericCells = 0;
    for(int k = 0; k < numOfRows; k++) {
    HSSFRow rowReading = sheetNow.getRow(k);
    if(rowReading != null) {
    HSSFCell cellReading = rowReading.getCell((short)j);
    if(cellReading != null) {
    if(cellReading.getCellType() == 0) {
    colTotal += cellReading.getNumericCellValue();
    numOfNumericCells ++;
    else if(cellReading.getCellType() != 0) {
    cellReading.setCellValue((double) 0.00);
    System.out.println(" \nSum of Column " + (j+1) + " is " + colTotal);
    System.out.println(" \nAverage of Column " + (j+1) + " is " + (colTotal/numOfNumericCells));
    readFile.close();
    catch(FileNotFoundException ex1) {
    ex1.printStackTrace();
    catch(IOException ex2) {
    ex2.printStackTrace();
    catch(NullPointerException ex3) {
    ex3.printStackTrace();
    The above code can successfully read the excel document and caliculates the sum and averages of the columns, can any one please help me in writing the same into the same file in additional rows. Thank you very much for your time.

    May be you can try to create a temporary copy of the file, do your update on it and then overwrite the original.
    Edited by: jgagarin on Jun 3, 2008 6:55 PM

  • How to set two different welcome-file to different servlets in web.xml

    Hi friends,
    Can some one help with web.xml file
    I have to different servlets in applications.
    I want to set two different welcome files for my two different
    servlets in web.xml
    Please, can some one give me sample code to achieve this.
    Here web.xml code:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!DOCTYPE web-app PUBLIC
    "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd">
    <web-app>     
         <servlet>
              <servlet-name>reports</servlet-name>
              <servlet-class>com.caremark.ivr.servlet.IvrReportsServlet</servlet-class>
         </servlet>
         <servlet-mapping>
              <servlet-name>reports</servlet-name>
              <url-pattern>/reports</url-pattern>
         </servlet-mapping>
         <session-config>
              <session-timeout>30</session-timeout>
         </session-config>
         <welcome-file-list>
              <welcome-file>reportsindex.jsp</welcome-file>
         </welcome-file-list>
         <servlet>
              <servlet-name>calldetails</servlet-name>
              <servlet-class>com.caremark.ivr.servlet.IvrCallDetailsServlet</servlet-class>
         </servlet>
         <servlet-mapping>
              <servlet-name>calldetails</servlet-name>
              <url-pattern>/calldetails</url-pattern>
         </servlet-mapping>
    <welcome-file-list>
              <welcome-file>calldetailsindex.jsp</welcome-file>
         </welcome-file-list>
    </web-app>
    I need this fix immediately. Your help will be really appreciated. Thanks in advance.

    First of all, my understanding is that you need to have a Servlet 2.4 complaint server to do this...Given that, you're supposed to be able to simply specify the Name of the servlet as the welcome-file to get it to work. For example:
    Your servlet section:
    <servlet>
      <servlet-name>Controller</servlet-name>
      <servlet-class>com.company.ControllerServlet</servlet-class>
    </servlet>Now you would add the following to your welcome file list:
    <welcome-file-list>
      <welcome-file>Controller</welcome-file>
    </welcome-file-list>Note that you use the servlet-name value from the servlet definition, NOT the url-mapping from the servlet-mapping section.
    Please note that I cannot verify this as I am running a 2.3 server at home. When I get to work Friday I can test on a 2.4 machine. However this shouldn't take you more than a minute to test.
    Note that I did try this on the 2.3 compliant server and it did NOT work (as I expected)...
    HTH.

  • Welcome file usage: can it be any URL?

    Hi,
    Do welcome-files have to always be concrete files such as .html or .jsp files? I am finding that when using Tomcat 4.0.1, if I specify a servlet mapping as a welcome file, I end up getting a directory listing.
    For example, since I am using Struts, I have specified a Struts action as my welcome-file, but Tomcat seems to ignore this altogether and I end up getting a directory listing. If I request the action directly, then I have no problems.
    Has anyone faced any similar issues?
    Regards,
    Steve

    Hi,
    I am also running into the same issue.
    Did you get any workaround?
    Please let know,
    thanx in advance
    -Pravir

  • Invalid element 'welcome-file-list' in content of 'web-app',

    HI, folks.
    I recently used struts to develop a simple web applicaiton, and whenever I tried to use tag libs
    such as /WEB-INF/struts-html.tld
    /WEB-INF/struts-html.tld and
    tried to compile it, it gives out compile error such as:
    Error(52,21): Invalid element 'welcome-file-list' in content of 'web-app', expected elements '[taglib, resource-env-ref, resource-ref, security-constraint, login-config, security-role, env-entry, ejb-ref, ejb-local-ref]'.
    if I remove the above tag libs, the jsp file compiles
    without any problem.
    Are you guys familiar with these problems?
    please let me know if I'm doing anything foolish.
    Thanks!

    Unless some other elements tag are not close correctly this error does not make sense. Can you cut and paste your web.xml?
    It should look something like:
    <?xml version = '1.0' encoding = 'windows-1252'?>
    <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
    <web-app>
    <welcome-file-list>
      <welcome-file>/untitled1.jsp</welcome-file>
    </welcome-file-list>
    <taglib>
      <taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>
      <taglib-location>/WEB-INF/struts-html.tld</taglib-location>
    </taglib>
    </web-app>Charles.

  • Images not displayed in welcome-file

    HI,
    I am working on JBoss 4.0.4 G.A.
    My applicaiton structure is as following
    <web-app>
    <web-app>/WEB-INF
    <web-app>/jsp ---> contains all the jsps
    <web-app>/images --> contains all the images
    <web-app>/html --> contains all the htmls
    <web-app>.js--> contains all the .js files
    My problem is that my welcom file is under jsp directory.
    I have made an appropriate entry in web.xml for the welcome page
    Welcome page is working fine but the only problem is that all the images on the welcome page are not displayed.
    Please help me solving this problem ....
    Thanks in advance

    Hi,
    Thanks for reply. I have checked that. I am refering to the correct directory. Bye the way, I have got the solution, the image files were not displayed because I was using relative path and context root was not set to my web app context itstead it was trying to take it relative to the server's bin directory. I just set <context-root>/<my web app root></context-root> in jbossweb.xml file and the problem was sloved.
    Regards,
    Jignesh
    Message was edited by:
    jignesh_shukla

  • Setting the welcome-file

    i have a problem something like this...
    i am setting my welcome-file im my web.xml to index.faces
    but i got allways this error 404 that this site does not exist....
    the stragne thing is that the massege says "/" could not found and not "index.faces" could mnot found:
    HTTP Status 404 - /
    type Status report
    message /
    description The requested resource (/) is not available.why is this happening?? i jhave index.faces file why it couldn't been found????
    plz help
    P.s.: if i set my welcome-file to onther xyz.html file...everything goes ok...

    here's a sample of what I did to set my welcome file using tiles
    edit struts-config and add these lines under <global-forwards>
    <forward name="index" path="/.index.do" />index.do is defined under the action mappings and will be pointing to the definition name of the page i defined in tiles-def (.indexDef) as shown below:
    then under the <action-mappings>
    <action path="/index"
                   type="org.apache.struts.actions.ForwardAction"
                   parameter=".indexDef" /> in my tiles-def i have a base definition which all layouts extend and this is what .indexDef is:
    <definition name=".indexDef" extends=".baseDef">
              <put name="title" value="..." />
              <put name="body" value="/WEB-INF/tiles/indexBody.jsp" />
         </definition> hope this helps. if you still can't do it, kindly post your struts-config, tiles-def files :D

  • Servlet as a welcome file: is it a myth?

    Hello
    There are many articles on the web that espouse that Servets 2.4 allow for a servlet to be specified as a welcome file thusly (taken from OnJava.com):
    First, register the servlet in web.xml.
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <web-app xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi=
    "http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=
    "http://java.sun.com/xml/ns/j2ee
    http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
    <servlet>
    <servlet-name>MyServlet</servlet-name.
    <servlet-class>com.jspservletcookbook.MyServlet</servlet-class>
    </servlet>
    <!-- optionally map the 'MyServlet' servlet to a URL pattern -->
    <servlet-mapping>
    <servlet-name>MyServlet</servlet-name>
    <url-pattern>/myservlet</url-pattern>
    </servlet-mapping>
    <!-- rest of web.xml ... -->
    Then create a welcome-file element in web.xml that specifies the registered servlet name.
    <welcome-file-list>
    <welcome-file>MyServlet</welcome-file>
    <welcome-file>default.jsp</welcome-file>
    </welcome-file-list>
    Make sure to use the servlet name in the welcome-file element without a forward slash (/) preceding it.
    Poppycock I say. At least it's not working for me with either Tomcat 5 or Tomcat 5.5. Has anyone out there ever seen this work on Tomcat?

    It most certainly is possible now, but wasn't until rather late in TC 5.0.xx series I believe (5.0.18 or so?). You can chack the change logs to id exactly when...
    But the reason it isn't working for you is you have to match the value in your <welcome-file> to the URL in the servlet's <url-pattern> servlet mapping. So your web XML should look like this:
    <servlet>
      <servlet-name>MyServlet</servlet-name.
      <servlet-class>com.jspservletcookbook.MyServlet</servlet-class>
    </servlet>
    <servlet-mapping>
      <servlet-name>MyServlet</servlet-name>
      <url-pattern>/myservlet</url-pattern>
    </servlet-mapping>
    <welcome-file-list>
      <welcome-file>myservlet</welcome-file>
      <welcome-file>default.jsp</welcome-file>
    </welcome-file-list>Your porblem was case. Your url-pattern had lower case, but the welcome-file had upper case letters like the servlet name.
    Here is an example app that I tested and worked:
    //The servlet:
    package net.thelukes.steven;
    import java.io.IOException;
    import java.io.PrintWriter;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    public class WelcomeServlet extends HttpServlet {
         public void doGet(HttpServletRequest request, HttpServletResponse response)
           throws ServletException, IOException {
              PrintWriter out = response.getWriter();
              out.println("Hello World");
              out.flush();
              out.close();
    //the web.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app id="WebApp_ID" version="2.4"
             xmlns="http://java.sun.com/xml/ns/j2ee"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
                                 http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
         <display-name>WTPTest</display-name>
         <servlet>
              <servlet-name>Welcome</servlet-name>
              <servlet-class>net.thelukes.steven.WelcomeServlet</servlet-class>
         </servlet>
         <servlet-mapping>
              <servlet-name>Welcome</servlet-name>
              <url-pattern>/welcome</url-pattern>
         </servlet-mapping>
         <welcome-file-list>
              <welcome-file>welcome</welcome-file>
         </welcome-file-list>
    </web-app>
    //The address I typed (the web app is names WTPTest
    http://localhost:8080/WTPTest
    //The HTML Output
    Hello World

  • How to use random access file to access file in disk?

    I have tried to use random access file stream to access the some files saved in disk, but not very successful. I want to know how I can find a particular file in the disk with file locator or sth else.
    Suggestion is highly welcomed, if you have codes to put, I will test it.

    The scenerao is:
    create a randomAccessfile
    write 100 blank records( for future use)
    open this file
    write data to the records inside file
    close the file.
    I will try to put a testing code for you later on.

  • Create pdf using a .xdp file and iText

    Hello experts,
    my question is regarding the generation of a pdf file using a .xdp file and the iText API. I have an .xdp file of a designed form and I would like to generate a pdf using this file, the iText API and the context.
    Is it possible? are there any tutorials or examples? any help is welcome!
    Thanks in advance.
    Alperen

    Hi,
    Please check the following links:
    How to import an xdp-File to Web Dynpro Interactive Forms
    https://wiki.sdn.sap.com/wiki/display/XI/CODE-CreateaPDFFileviatheiText+Library
    Sample project how to use Itext (pdf) in webdynpro
    Itext PDF Creation
    Regards.
    Rajat

  • In Web.xml  welcome file tag not works

    Hi All ,
    I am developing simple web application using spring framework
    when i am try to add welcome file tag in web.xml with respective welcome page path but it not works.
    but when use jsp page without to having any property it works.
    what the problem with me
    Thanks

    Hi Frank
    Thank you for your reply.
    This is how I registered the session filter in web.xml
    <filter>
    <filter-name>SessionFilter</filter-name>
    <filter-class>com.avery.view.filter.SessionFilter</filter-class>
    </filter>
    <filter-mapping>
    <filter-name>SessionFilter</filter-name>
    <url-pattern>/faces/*.jsf</url-pattern>
    </filter-mapping>
    I'll try to use phaselisenter as you suggested.
    Also, one more thing please, in the session filter, I have something like this.
    public void doFilter(ServletRequest request, ServletResponse response,
    FilterChain chain) throws IOException, ServletException {
    System.out.println("JF--- Calling the Filter");
    if (request instanceof HttpServletRequest) {
    HttpServletRequest httpRequest = (HttpServletRequest)request;
    HttpServletResponse httpResponse = (HttpServletResponse)response;
    HttpSession session = httpRequest.getSession();
    String url = httpRequest.getPathTranslated();
    String path = httpRequest.getContextPath() + httpRequest.getServletPath();
    if (httpRequest.getRequestURI().equals(path+"/Login")) {
    System.out.println(" the request path is" + httpRequest.getRequestURI().toString());
    session.setAttribute("WELCOME", Boolean.TRUE);
    chain.doFilter(request, response);
    else if (session.getAttribute("WELCOME") == null){
    httpResponse.sendRedirect(path+"/Login");
    else {
    chain.doFilter(request, response);
    else {
    chain.doFilter(request, response);
    Do you think it looks right ?
    thanks
    Edited by: Lang on Apr 13, 2012 1:41 AM

Maybe you are looking for

  • Hi, Could anyone help me with variables in BEx

    Hi,   I want to know what a Variable is,when and how it is used in BEx Reporting. I am aware that Variables are very important in BEx, but i don't know where to use it. I know how to create a query report,but where will i use this variables and how,w

  • Not working, Extension in Photoshop CC

    Hello  Do Not working, Extension in Photoshop CC ... not active why?. OSX 10.9 Chris Zatycki

  • How to save a FORM as DATABASE

    Hello everyone I am using forms 9i with Database 9i and 9iAS . I want to save a form as database . In previous version we had the option so save as file or database . We were able to set it under tools- preferences . But in forms 9i I don't find it a

  • IOS Developer program enrolment closed?

    https://developer.apple.com/programs/ios/ If I click "Enroll" it just says we'll be back soon. Any ideas? Is it closed for Christmas? I really wanted to register and submit my app now...

  • Cannot hear any sound

    My repo wirless sound system is installed correctly but I cannot hear sound in my headphone.