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
13
votes
3 answers

link directly to GSP

In a GSP, is it possible to create a direct link to another GSP? I know I can use: and in UserController define the foo action to just show the corresponding GSP class UserController { def foo =…
Dónal
  • 185,044
  • 174
  • 569
  • 824
13
votes
1 answer

How to do looping in GSP?

I have GSP file in which i will be getting a value from the controller say for example ${paramsValue?.ruleCount} is 3 and based on that I have to create table rows. Is there any way to do it in gsp
Siva
  • 289
  • 1
  • 6
  • 16
12
votes
3 answers

Text field validation Using Jquery

I have 5 text field in 5 rows like this..
maaz
  • 3,534
  • 19
  • 61
  • 100
12
votes
6 answers

How to prevent Grails from caching old versions of gsp file?

I am making modifications to /grails-app/views/index.gsp. When I save the file and refresh http://localhost:8080/index.gsp in Firefox, I am getting an old version of the file. Is there a way to prevent Grails from caching and rendering old versions…
Emmett
  • 14,035
  • 12
  • 56
  • 81
12
votes
2 answers

using value of enum in g:select when enum is attribute of selection object

Example: batchTag is an enumerated type attribute of a batchRange, with values like so: JAN1 "January Biweekly 1", JAN2 "January Biweekly 2", etc. I want to display the VALUE of the batchTag in the select, IOW, the select should contain "January…
Alexx
  • 3,572
  • 6
  • 32
  • 39
11
votes
4 answers

Intercepting Grails GSP actions on either client or server side

Grails 2.4.5 here. I am trying to implement the following UX behavior for my GSPs: If a user has permission to click a button, then they may do so; however If the user doesn't have permission to click a button, then when they click the button, a…
smeeb
  • 27,777
  • 57
  • 250
  • 447
11
votes
1 answer

ERROR errors.GrailsExceptionResolver - ConcurrentModificationException occurred when processing request:

I have a Grails 2.4.5 GSP page which loads two iFrame: