what is Jsp? types of scripting elements in Jsp.

 

<———————————————————-J2EE—————————->

GM friends how are you ?

So  today we are going to learn about jsp (component of advance java)  and expression tag in jsp and and we are going to learn about a little about jstl(java standard tag library.)

J2EE =java to enterprise edition.

j2ee module is used  to develop the following applications.

1.web applications .

 

2.distributed  applications.

3.Enterprise applications.

4.N- tier applications.

<———————————- JSP————————->

JSP is a dynamica progrmming language .

It is capable of making simple program to complex program.

An HTML page with some java code sprinkled in jsp.

JSP is processed on the server. (tomcat,glassfish ,javaserver etc)

result of java code included in html returned to browser.

A jsp consists  of html tag and jsp tag.

Jsp is a technology used to create web applications just like servlet technology.

IT can be thought  as an extension of servlet because more functionality than servlets. such as expression  language ,jstl etc.

the JSp pages are easier to maintain then servlet because we can separate designing  and development .

IT provides same additional feature such as expression language ,custom tags etc.

There are three types of  JSP expression.

  1. JSP expression    <%=   some java expression %>

2.  JSP Scriptlet =  <%= some java code: 1  to many lines %>

3    .JSP declaration = <%!  variable  or method declaration %>

JSP expression:———————————————————–

<html>

<body>

<h1>converting a string to uppercase:</h1>

<% =  new String(“hello world”).to uppercase()%>

</body>

</html>

———————————————————————————————-

output:- HELLO WORLD

JSP Scriptlets:———————————————————————-

insert 1 to many lines of java code.

to include content in the page use: out.println.

example:——————————

<html>

<body>

<h1>jsp scriptlet </h1>

<%

for (int i=1;i<=5;i++)

{

out.println(“the numbers in the loop”+i);

}

%>

</body>

</html>

output:-the numbers in the loop 1

the numbers in the loop 2

the numbers in the loop 3

the numbers in the loop 4

the numbers in the loop 5

JSP declarations:———————————————————————————————————————————————————————–>

Declare a  method in the jsp tag.

Call the method in the same jsp page.

the declarations tag .

<% !

write some code



%>

example:———————————————————————————

<html>

<body>

<h3>declarations tag</h3>

<%!

String make it lower(String data)

{

return data to Lowercase();

}

%>

Lower case”HELLO WORLD”-

<%=  makeitLower(“hello world”) %>

</body>

</html>

output:—-

declaration tag

hello world

 

thank you hope you will like this article and get benefited.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *