facebook

Blank JSP output

  1. MyEclipse IDE
  2.  > 
  3. Java EE Development (EJB, JSP, Struts, XDoclet, etc.)
Viewing 15 posts - 1 through 15 (of 18 total)
  • Author
    Posts
  • #231677 Reply

    John Brosan
    Member

    Hello,

    I am using the following:

    MyEclipse 3.8.4
    JBoss 4.0.2
    Sun JDK 1.5.0_3
    jTDS 1.0.3
    MyFaces 1.0.9

    I’ve setup an Enterprise application and I am able to start and stop the JBoss server cleanly and without errors in the MyEclipse IDE. I’ve added a few web projects as well.

    However, when I add a simple JSP page using the default template, I don’t get any output. The output should say, “This is my JSP page.” I don’t believe that my page is actually being executed as the debugger does not stop at the breakpoint. Also the JSP is compiled to the .class file as can be seen in my deployment folder.

    The JSP is in my WebRoot directory.

    If I view the source of the page this is the only output I get. I’m sure I am missing something or doing something silly. Any assistance would be most appreciated.

    Output of JSP. It doesn’t contain anything that I’ve put in it. Neither content nor title.

    <html><body></body></html>

    Thanks,
    John[/img][/list]

    #231706 Reply

    Riyad Kalla
    Member

    John,
    Sounds like you are hitting an invalid page and getting some default blank page contents sent back to you. What is the name of your JSP page and what is the web context name? What URL are you using to access that JSP page AND what URL mappings do you have in your web.xml file?

    #231767 Reply

    John Brosan
    Member

    Riyad,

    JSP Name: test.jsp
    Context: /MyMain
    URL: http://localhost:8080/MyMain/test.jsp

    Web.xml is as follows:

    I think it may be due to how I’ve got MyFaces 1.0.9 setup. But I am not sure.

    
     <?xml version="1.0" encoding="UTF-8"?>
    <web-app 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">
    
    
        <context-param>
            <param-name>javax.faces.CONFIG_FILES</param-name>
            <param-value>
                /WEB-INF/faces-config.xml
            </param-value>
        </context-param>
    
        <context-param>
            <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
            <param-value>server</param-value>
        </context-param>
    
        <context-param>
            <param-name>org.apache.myfaces.ALLOW_JAVASCRIPT</param-name>
            <param-value>true</param-value>
        </context-param>
        
        <context-param>
            <param-name>org.apache.myfaces.DETECT_JAVASCRIPT</param-name>
            <param-value>false</param-value>
        </context-param>
    
        <context-param>
            <param-name>org.apache.myfaces.PRETTY_HTML</param-name>
            <param-value>true</param-value>
        </context-param>
    
        <context-param>
            <param-name>org.apache.myfaces.AUTO_SCROLL</param-name>
            <param-value>true</param-value>
        </context-param>
    
    
        <!-- WelcomeFile Filter -->
    
        <!-- Extensions Filter -->
        <filter>
            <filter-name>extensionsFilter</filter-name>
            <filter-class>org.apache.myfaces.component.html.util.ExtensionsFilter</filter-class>
            <init-param>
                <param-name>uploadMaxFileSize</param-name>
                <param-value>100m</param-value>
            </init-param>
            <init-param>
                <param-name>uploadThresholdSize</param-name>
                <param-value>100k</param-value>
            </init-param>
        </filter>
    
    
    
        <filter-mapping>
            <filter-name>extensionsFilter</filter-name>
            <url-pattern>*.jsf</url-pattern>
        </filter-mapping>
        <filter-mapping>
            <filter-name>extensionsFilter</filter-name>
            <url-pattern>/faces/*</url-pattern>
        </filter-mapping>
    
    
    
        <!-- Listener, that does all the startup work (configuration, init). -->
        <listener>
            <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
        </listener>
    
    
        <!-- Faces Servlet -->
        <servlet>
            <servlet-name>Faces Servlet</servlet-name>
            <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
            <load-on-startup>1</load-on-startup>
        </servlet>
    
    
    
        <!-- extension mapping -->
        <servlet-mapping>
            <servlet-name>Faces Servlet</servlet-name>
            <url-pattern>*.jsf</url-pattern>
        </servlet-mapping>
    
    
        <!-- Welcome files -->
    
    
    
    </web-app>
    
    

    Thanks,
    John

    #231775 Reply

    Riyad Kalla
    Member

    Hmm, looks straight forward enough. What is the code of the JSP page itself?

    #231781 Reply

    John Brosan
    Member

    Riyad,

    Here is the code of the JSP. Its just the default thats generated by MyEclipse.

    
     
    <%@ page language="java" import="java.util.*" %>
    <%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    %>
    
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
      <head>
        <base href="<%=basePath%>">
        
        <title>My JSP 'test.jsp' starting page</title>
        
        <meta http-equiv="pragma" content="no-cache">
        <meta http-equiv="cache-control" content="no-cache">
        <meta http-equiv="expires" content="0">
        <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
        <meta http-equiv="description" content="This is my page">
        
        <!--
        <link rel="stylesheet" type="text/css" href="styles.css">
        -->
      </head>
      
      <body>
        This is my JSP page. <br>
      </body>
    </html>
    
    

    I’m not sure if this has any bearing on the issue or not, but this web-project is part of an Enterprise Project. There are other web-projects contained within the main project.

    On one of the other web-projects I did not setup MyFaces for it, and the test.jsp file works fine there. After doing some reading, I thought that getting the latest Milestone version of 4.0 and the appropriate version of Eclipse might help with the issue since it seems to support MyFaces, but I am still getting the same results.

    Thanks,
    John

    #231789 Reply

    Riyad Kalla
    Member

    John,
    This isn’t really an ME issue, this is just a web app issue that you would be having even if ME wasn’t involved. I would typically say this is caused by a funky mapping but in your case your mappings look ok. What I would suggest is creating a new clean web project, run it. Did it work? Now add JSF capabilities to it. Redeploy it, run it, did it work? And just keep going step by step until it breaks.

    #231792 Reply

    John Brosan
    Member

    Hi Riyad,

    Thanks for the help. I’ll give your recomendation a try.

    Thanks,
    John

    #240985 Reply

    dhiraj31
    Member

    Hi,

    i am having same problem. When I hit try to view my page using URL :http://localhost:8090/testDB/login.faces
    I also tried http://localhost:8090/testDB/login.jsp just in case

    my web.xml is

    <?xml version=”1.0″ encoding=”UTF-8″?>
    <web-app xmlns=”http://java.sun.com/xml/ns/j2ee&#8221; xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance&#8221; version=”2.4″ xsi:schemaLocation=”http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd”&gt;
    <context-param>
    <param-name>javax.faces.CONFIG_FILES</param-name>
    <param-value>/WEB-INF/faces-config.xml</param-value>
    </context-param>
    <listener>
    <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
    </listener>
    <servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>0</load-on-startup>
    </servlet>
    <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.faces</url-pattern>
    </servlet-mapping>
    </web-app>

    when I put URL : http://localhost:8090/testDB/

    I can see my JSP there ….. please let me know what the problem is …. It has to be very basic and I am not sure what the problem could be.

    thank you

    #240992 Reply

    Riyad Kalla
    Member

    dhiraj31,
    When you enter in your localhost:8090/testDB/login.faces URL, what exactly happens? Do you see any messages in the console? Browser say anything?

    #253419 Reply

    elzombie
    Member

    Hi, I have the same problem. I just added a myfaces extensions filter to the web.xml , and now I get a blank page 🙁

    btw, if I use Mozilla, it works.

    If I remove the filter, it works in both ie & Mozilla.

    Thanks in advance

    #253438 Reply

    Riyad Kalla
    Member

    elzombie,
    I have no idea what is going on. Try using Shift-REFRESH, maybe IE is being to aggressive with the caching of the empty page.

    #253492 Reply

    jbm
    Member

    Hi there,

    I have a problem that seems to be similar. I have a JSF page, which shows up fine (in both IE and Firefox) in normal scenarios.

    But as soon as I apply servlet filters on the *.jsp file, I get into trouble. So after setting up the filters, when I load the same page(s) in each of the browsers, the filters run fine in the background, but the page comes up blank (in both IE and FF).

    Happening only with JSF / Faces pages.

    As elzombie mentioned above, once I removed the filter mapping, the page loads up just fine.

    Would appreciate any feedback on this. TIA!

    #255803 Reply

    fsteveb
    Member

    Same problem here. Very frustrating. I can create a html page and then rename it to jsp and it displays blank. Blank meaning there is nothing inside the <body> tag.

    I have build a simple web page and loaded to tomcat and displayed. Works great. If I rename that page to jsf, it displays blank. I’ve tried it in IE and Firefox and both are blank. I’ve tried doing the same thing on different computers, starting from a new project each time and always blank.

    What’s wierd is, the jsf samples DO display:

    \Apache Software Foundation\Tomcat 5.5\webapps\jsp-examples

    I tried some sample jsf pages and they don’t work either. It must have something to do with the configuration since the

    I tried adding the pages from the myfaces-components tutorial.
    http://www.coreservlets.com/JSF-Tutorial/#Section8

    When I load this page, I get a blank page, no errors, no server messages, nothing.
    http://localhost:8080/myfaces-components/date.faces

    Here is the source of the displayed page

    
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML><HEAD>
    <META http-equiv=Content-Type content="text/html; charset=iso-8859-1"></HEAD>
    <BODY></BODY></HTML>
    

    Seems like a common problem. There must be a simple reason.

    #255804 Reply

    Riyad Kalla
    Member

    I need to clarify for you guys that this is not a MyEclipse issue. Running your JSP pages in your application server and having them host back to you as blank is most likely a configuration or faulty install issue.

    That being said, let’s take this back to basics and make sure those work before we continue down this path and find out the real cause is something very small and and we rip all our hair out.

    1) Download a fresh copy of Tomcat 5.5.17 from here: http://www.tux.org/pub/net/apache/dist/tomcat/tomcat-5/v5.5.17/bin/apache-tomcat-5.5.17.zip (note I’m linking to the zip on purpose)
    2) Unzip this to a new directory, like C:\test\ (unzipping the ZIP will create the tomcat-5.5.17 subdir)
    3) Go into MyEclipse, find your Tomcat 5 connector settings and update the Home dir to point to this new dir (make sure you stopped the old app server before doing this).
    ** NOTE, only change the first page, Launch should be left to Debug, Paths should all be empty and JDK should be set to some JDK 1.4 or greater that you have on your system (not a JRE)
    4) Remove your old deployment for your project
    5) Create a new Web Project, name it something like “TestWeb”.
    6) Create a single JSP page using the default JSP template, name it index.jsp
    7) Deploy your project to TOmcat, start Tomcat, check http://localhost:8080/TestWeb , do you see your page?
    8) Good, now create another test project, name it TestWebJSF. Add a single JSF page using the default JSF template and name it index.jsp
    9) Deploy it, then access http://localhost:8080/TestWebJSF/index.faces , do you see your pages?

    #255809 Reply

    fsteveb
    Member

    I realize this is probably not a myeclipse problem, but it may have something to do with the xml files it generates.

    Everything works fine until step 9, I get an error, it can’t find the resource.

    You said

    Add a single JSF page using the default JSF template

    I don’t see any jsf templates. I added another jsp page from the jsp template.
    If I load the .jsp it loads fine, if I say .faces, error.

    HTTP Status 404 - /TestWebJSF/index.faces
    
    --------------------------------------------------------------------------------
    
    type Status report
    
    message /TestWebJSF/index.faces
    
    description The requested resource (/TestWebJSF/index.faces) is not available.
    --------------------------------------------------------------------------------
    
    Apache Tomcat/5.5.17
    
Viewing 15 posts - 1 through 15 (of 18 total)
Reply To: Blank JSP output

This topic is marked as closed to new replies, however your posting capabilities still allow you to do so.

You must be logged in to post in the forum log in