Questions tagged [gsp]

Groovy Server Pages (GSP) is a presentation language for web applications, similar to JSP. GSP allows static and dynamic content to be mixed in the same document. The result is a dynamically generated HTML, XML or other type of document in response to a Web client request.

Groovy Server Pages (GSP) is a view technology which can be used for designing web application using Grails Framework. Developing GSP are very much similar to that of designing web pages with Active Server Pages (ASP) and Java Server Pages (JSP) but coding is very much simpler and easier than both of them. Users are provided with facility of having static, dynamic as well as mix of both contents at a time in a single application.

The output can be dynamically rendered to different forms like : HTML, XML, text and any other format based on Web client request object.If you are beginner in learning groovy, please read Introduction to Groovy – Scripting Language.

Advantages of using GSP using Grails

  1. A GSP uses Groovy GString for evaluation of expression generally using ${….} but whereas in JSP EL expressions are used for the same purpose but they are restricted only to object navigation to overcome this disadvantage JSTL functions can to be written for creating static helper methods, registering them through a taglib descriptor, adding a taglib declaration and finally implementing them using the function.
  2. A developer has been provided with Logical and Iterative tags in GSP with safe navigation operator and Elvis operator which can be implemented easily to fetch the needed results according to their requirement. For example these operators can be implemented in this manner: Safe navigation operator :${book.pages?.no()}
  3. Elvis operator : ${totalpages ?: 100}
  4. A GSPhas ability for invoking methods through Grails dynamic tags which makes it easier to produce well-formed markup:
<!-- With a regular tag -->
<a href="<g:createLink action="list" />">Click here</a>
<!-- As a method call -->
<a href="${createLink(action:'list')}">Click here</a>
  1. Creating and testing custom tag libraries using GSP are very easier then JSP since there is no need for developer to code tld files and taglib declarations.
1323 questions
5
votes
1 answer

Custom denied.gsp styles not rendering

I am using the spring-security-core plugin and I have created a custom denied.gsp page under /views/login/denied.gsp. If I go to the page directly via /login/denied I can see that the layout was applied. However, if I attempt to access a…
brwngrldev
  • 3,664
  • 3
  • 24
  • 45
5
votes
3 answers

How does one make a Grails application designer friendly without the need to re-deploy after a change to the view?

It has been a long while since I have really worked with J2EE so please excuse my ignorance. My recent engagement in a Grails project has peaked my interest in Java once more and especially in Grails as it makes building web applications on the Java…
Amir Khawaja
  • 459
  • 1
  • 6
  • 13
5
votes
8 answers

How can I change the way GRAILS GSP fieldValue formats Integers?

I have a field in my domain object which I define as an Integer... Integer minPrice I then access it in a GSP page as follows: ${fieldValue(bean: myBean, field: 'minPrice')} and what I get in my HTML is... 100,000 which is not an Integer, it's a…
Simon
  • 78,655
  • 25
  • 88
  • 118
5
votes
2 answers

Correctly pass a Groovy list to Javascript code in GSP

I'm making a web application with Grails. I've got a list with data that must be included on JavaScript to perform some dynamic load on