Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rendering a JSP view in a Grails 3 application #110

Closed
4 tasks done
MiguelAngelGarciaGomez opened this issue Jul 8, 2021 · 0 comments
Closed
4 tasks done

Rendering a JSP view in a Grails 3 application #110

MiguelAngelGarciaGomez opened this issue Jul 8, 2021 · 0 comments

Comments

@MiguelAngelGarciaGomez
Copy link

MiguelAngelGarciaGomez commented Jul 8, 2021

Task List

  • Steps to reproduce provided
  • Stacktrace (if present) provided: stacktrace.log
  • Example that reproduces the problem uploaded to Github
  • Full description of the issue provided (see below)

Steps to Reproduce

  1. Go to http://localhost:8080/index/start

Expected Behaviour

The JSP should be rendered.

Actual Behaviour

The JSP is not rendered and the following error is shown:

Could not resolve view with name '/index/first.jsp' in servlet with name 'grailsDispatcherServlet'

Adding DEBUG level to the log, the following relevant information is shown:

2021-07-08 13:13:18.971 DEBUG --- [nio-8080-exec-2] o.g.w.s.view.GrailsLayoutViewResolver    : Resolving view for name /index/first.jsp and locale en
2021-07-08 13:13:18.971 DEBUG --- [nio-8080-exec-2] o.g.w.s.view.GroovyPageViewResolver      : Locating GSP view for controller es.salenda.test.entrada.IndexController@2ffd5d39 and path /index/first.jsp
2021-07-08 13:13:18.971 DEBUG --- [nio-8080-exec-2] org.grails.core.io.StaticResourceLoader  : Loading resource for path /grails-app/views/index/first.jsp.gsp from base resource URL [file:/Users/miguelangelgarciagomez/Projects/testGrails3.3.9.JSP/]
2021-07-08 13:13:18.971 DEBUG --- [nio-8080-exec-2] org.grails.gsp.GroovyPageResourceLoader  : Resolved GSP location [/grails-app/views/index/first.jsp.gsp] to resource [URL [file:/Users/miguelangelgarciagomez/Projects/testGrails3.3.9.JSP/grails-app/views/index/first.jsp.gsp]] (exists? [false]) using base resource [URL [file:/Users/miguelangelgarciagomez/Projects/testGrails3.3.9.JSP/]]
[...]

Where it can be checked that it's trying to obtain the view name first.jsp.gsp, so the suffix .gsp is added.

Digging deeper into the classes involved, it seems that when the method GroovyPagesUriSupport#getAbsoluteViewURIInternal is called, the .gsp suffix is automatically added. I have debugged this method an storing includeSuffix as false, the suffix is not added and it works as expected, and this is the log shown:

2021-07-08 13:18:26.273 DEBUG --- [nio-8080-exec-9] o.g.w.s.view.GroovyPageViewResolver      : Locating GSP view for controller es.salenda.test.entrada.IndexController@2ffd5d39 and path /index/first.jsp
2021-07-08 13:18:37.490 DEBUG --- [nio-8080-exec-9] org.grails.core.io.StaticResourceLoader  : Loading resource for path /grails-app/views/index/first.jsp from base resource URL [file:/Users/miguelangelgarciagomez/Projects/testGrails3.3.9.JSP/]
2021-07-08 13:18:37.490 DEBUG --- [nio-8080-exec-9] org.grails.core.io.StaticResourceLoader  : Found resource for path /grails-app/views/index/first.jsp from base resource URL [file:/Users/miguelangelgarciagomez/Projects/testGrails3.3.9.JSP/]
2021-07-08 13:18:37.490 DEBUG --- [nio-8080-exec-9] org.grails.gsp.GroovyPageResourceLoader  : Resolved GSP location [/grails-app/views/index/first.jsp] to resource [URL [file:/Users/miguelangelgarciagomez/Projects/testGrails3.3.9.JSP/grails-app/views/index/first.jsp]] (exists? [true]) using base resource [URL [file:/Users/miguelangelgarciagomez/Projects/testGrails3.3.9.JSP/]]
2021-07-08 13:18:37.490 DEBUG --- [nio-8080-exec-9] o.g.w.s.view.GroovyPageViewResolver      : Resolved GSP view at URI [/index/first.jsp]
2021-07-08 13:18:37.491 DEBUG --- [nio-8080-exec-9] o.grails.gsp.compiler.GroovyPageParser   : Preprocessing /Users/miguelangelgarciagomez/Projects/testGrails3.3.9.JSP/grails-app/views/index/first.jsp for sitemesh. Replacing head, title, meta and body elements with sitemesh:capture*.

So I'm not sure whether is a configuration that I missed or it's a bug.

Environment Information

  • Operating System: macOS Big Sur 11.4
  • Grails Version: 3.3.9
  • JDK Version: openjdk version "1.8.0_212"

Example Application

puneetbehl added a commit that referenced this issue Aug 9, 2023
Resolve ability to render jsp pages if jstl is installed. Fixes #110
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant