What is use of % symbol in JSP

What is use of % symbol in JSP? Please reply
[51 byte] By [johnjustusca] at [2007-11-27 2:20:52]
# 1
<% starts jsp tag%> end jsp tagit is like <html> and </html> (html)<? and ?> (php)<script> and </script> (javascript)
radicjesa at 2007-7-12 2:22:39 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
it allows you to write hideous, PHP-like code that's a bi tch to maintain
georgemca at 2007-7-12 2:22:39 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
Below is an example of what a JSP tag looks like.<some:tag>body</some:tag>Here is an example of a JSP tag with attribute.<jsp:include page="hello.jsp"/>
GhostRadioTwoa at 2007-7-12 2:22:39 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
JSP Directives and Scripting Elements Directives <%@ directive %> Declarations <%! declaration %> Expressions <%= expression %> Code Fragment/Scriptlet <% code fragment %> Comments <%-- comment --%> Hope that
javavoyagera at 2007-7-12 2:22:39 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5

> What is use of % symbol in JSP? Please reply

Some people on this thread have provided you good answers.

You may also want to know that the new way of writing JSPs is with JSTL and scriptlets <% anything that goes here is a scriptlet %> are discouraged.

But it's good to get basic foundation in scriptlets too incase there's legacy JSP code.

appy77a at 2007-7-12 2:22:39 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6
> it allows you to write hideous, PHP-like code that's> a bi tch to maintainI forgot to write that ;)It is discouraged to write actual JSP inside a JSP file, use tags / JSTL for that
radicjesa at 2007-7-12 2:22:39 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 7
> it allows you to write hideous, PHP-like code that's> a bi tch to maintainLol, I've never seen a better description.
BalusCa at 2007-7-12 2:22:39 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 8

> > What is use of % symbol in JSP? Please reply

>

> Some people on this thread have provided you good

> answers.

>

> You may also want to know that the new way of writing

> JSPs is with JSTL and scriptlets <% anything that

> goes here is a scriptlet %> are discouraged.

>

> But it's good to get basic foundation in scriptlets

> too incase there's legacy JSP code.

why would you need a foundation in scriptlets, though? if it's legacy code, it's already there, and it's just java. if you can't work out that the stuff that looks like java code in a legacy JSP actually is java code, you're in trouble. and wouldn't part of the maintenance be to refactor the scriptlets out?

georgemca at 2007-7-12 2:22:39 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 9
If you write any thing between <% %>, the compiler considers it as java code.For every start tag, the compiler searches for the end tag. Other wise it'll return error.Message was edited by: Panduranga
Pandurangaa at 2007-7-12 2:22:39 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 10

Everything in a Java Server Page file (tags, scriplets,) is converted into a Java Servlet by the JSP Engine. After the Java Server Page is transformed into a Java source file, the compiler compiles the Java source file and creates a Java class file. Inside a Java Runtime Environment, a Java Virtual Machine reads the Java class file and executes its program instructions.

GhostRadioTwoa at 2007-7-12 2:22:39 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 11

> > > What is use of % symbol in JSP? Please reply

> >

> > Some people on this thread have provided you good

> > answers.

> >

> > You may also want to know that the new way of

> writing

> > JSPs is with JSTL and scriptlets <% anything that

> > goes here is a scriptlet %> are discouraged.

> >

> > But it's good to get basic foundation in

> scriptlets

> > too incase there's legacy JSP code.

>

> why would you need a foundation in scriptlets,

> though? if it's legacy code, it's already there, and

> it's just java. if you can't work out that the stuff

> that looks like java code in a legacy JSP actually

> is java code, you're in trouble. and wouldn't

> part of the maintenance be to refactor the scriptlets

> out?

It's not really just Java IMO because JSP has additional concepts like

implicit objects such as page, request, session, out etc - a newbie who knows Java won't have a clue when the come across the implicit objects and can't find where they were declared.

Also the concept of directives is not in Java Classes but on in JSPs.

JSP has some features that would be new or confusing to someone who has only worked with Java, therefore a newbie to JSP would be better off learning JSP concepts.

-regards

appy

appy77a at 2007-7-12 2:22:39 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...