Grails renders JSP as blank page
I have a Grails application with a JSP page (I am porting a legacy JSP application). For some reason, the page is completely cleared. Looking at the HTTP headers I see it 200 with content length 0.
HTTP/1.1 200 OK
Content-Language: en-US
Content-Type: text/html; charset=iso-8859-1
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Set-Cookie: JSESSIONID=1sh9r73vqvukj;Path=/myGrailsApp
Content-Length: 0
Server: Jetty(6.1.12)
A page is a combination of HTML, tags ( ${property}
), JSP includes ( <jsp:include>
) and short snippets of code ( <% code %>
yes, I know this is a bad idea). Nothing is displayed in the log file or console, indicating an error. Does Grails hide the exception or error in some way?
Edit: The problem is with the JSP <jsp:include/>
include tag . If I remove all JSPs then Grails renders. Is Grails JSP compatible? Since the JSP functionality is provided by the web application (Jetty, Tomcat), I think yes.
Edit: This happens with Grails 1.0.4 and 1.1 beta 2 (1.1 claims to have added JSP support)
source to share
Yes, Grails is JSP compliant.
Completely empty? So if you "show the source" you don't get anything?
If you're an IntelliJ user, you can install the Grails plugin, set a breakpoint, and run the code to see what's going on.
Other things I've checked are JSTL versions and standards. These changes depend on the version of the servlet / JSP you are using.
source to share
It looks like you are deploying tag libraries incorrectly. We need to know the application server you are using to help you further.
Edit: Another thought - maybe the include tag works, but there is a compilation error in the contained content. Have you tried to simply return the included content?
source to share
Obviously you have decided to solve this problem by this time, but this is a solution for others.
I faced the same problem today:
This is the section of code from main.gsp
(LAYOUT)
<head>
<g:layoutTitle default="Grails" />
<g:layoutHead />
<g:javascript src="jquery-1.6.1.min.js" />
</head>
And this is mine index.gsp
<head>
<title>${title}</title>
<meta name="layout" content="main" />
</head>
What I was doing was dynamically building title
from index.gsp
and using a layout main
. title
is a required attribute of the html tag head
. So I missed the name as meaning by mistake null
. and it didn't show the expected page.
So the solution is:
- If you need a static header, don't use the tag
title
in the gsp file. In the above case, it will use itGrails
as the default title. - If you need a dynamic title, make sure it doesn't match the value
null
.
You might have a different problem, but it might also result in a blank page.
source to share