Advertisement
Guest User

sayHelloWithAttr.tag

a guest
Dec 2nd, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. <%@ tag language="java" %>
  2. <%@ attribute name="color" required="false" %> <!-- the color attribute -->
  3. <%@ attribute name="size" required="false" %> <!-- the size attribute -->
  4. <%
  5. String varColor; //local variable for varcolor
  6. int varSize; //size variable
  7.  
  8. try {
  9. varSize = Integer.parseInt(size); //parse the size arrtibute to integer
  10. }catch(Exception e) {varSize = 12;}
  11.  
  12. if(color != null) varColor = color; //if color has a value set varcolor to color
  13. else varColor = "black"; //if it is null
  14. %>
  15.  
  16. <h1 style="color:<%=varColor%>;font-size:<%=varSize%>px;">hello there from jsp tag</h1>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement