Tuesday, 15 September 2015

jstl - Custom Tag to use another JSPs in your JSP based on conditions -


I have a requirement where I need to include JSP in some JSP, and the path of JSP that I need to include Depends

I used getJspContext (). Include (), but it corrupts future requests.

That's why I started using getJspBody (). (String Writer Writer). / P>

The problem I am facing will execute GSP content in the custom tag, which is something like this:

  <% @ include file = "addressForm Jsp "% & Gt;  

However, I have to specify the path of JSP in the tag so that I can make different paths depending on different conditions.

I checked but I did not get it

P> This is my favorite way of including JSP:

    

and you can trigger the url parameter ($ {...} has a variable in the stuff).

  & lt; C: import url = "$ {path} / $ {} form .jsp" />  

In this example, $ {path} is a variable that you can set and with $ {form} If you want to play with this type, make sure that you can add it to the top of your JSP page:

  & lt;% @ taglib uri = "http: // Java.sun .com / jsp / jstl / core "prefix =" c "%>  

There are many examples and tutorials about the use of JSTL and "Core" tag libraries here:


No comments:

Post a Comment