• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Unable to understand Tag please help

 
sachin verma
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi I am preparing for SCWCD 5.0.
I found Tags very awful(not java type).
Please help me to understand Tags easily.
I cant answer the question like..

What are Tags?
Why the heck we need them?
what are the advantages?
Can't we work without tags?

Please help me guys
 
Abhijit Rai
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lets first see HTML tags
Html tags are a way to add functionality to HTML pages.
for example:
When I say <h1> Hello World</h1>,I mark (select) text "Hello World" .The functionality of tag <h1> is to change the text style and them send it to be displayed.
There are few tags which dont require a text section for example:
<br/>
In JSP its basically the same.
The JSP tags are used in JSP pages only(not in HTML pages).
Some JSP tags are standard while we could make them ourselves too.

I would suggest you better study basic html before learning JSP tags .

Cheers .
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What are Tags?

You may want to work through this Tutorial on tag libraries.

Why we need them?

You don't need them. But they can make life a lot simpler, and take care of repetitive tasks. Think of them as "methods for web apps". You don't need methods in normal Java code - you could just write everything in one big heap of code. But structuring it into methods makes for readable, maintainable and reusable code. Tags do a similar job for web pages.

Can't we work without tags?

Sure you can. But then, you don't need JSPs either, because you can write servlets that do the same thing. And then, you don't really need servlets, because you can write Java code that reads requests on port 80 and returns the appropriate results. And of course you don't need Java at all, because you could write the same in Assembler. This is an exaggeration, but you get the point - it's about abstraction.

There's a standard tag library called JSTL that takes care of a number of things you may want to do in many JSPs. You should read the "Introduction to JSTL" series linked in the http://faq.javaranch.com/java/JspFaq It will give you a better understanding of why you might want to use tags in general (and JSTL in particular).
[ November 13, 2008: Message edited by: Ulf Dittmer ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic