JSP | Expression tag
Expression tag is one of the scripting elements in JSP. Expression Tag in JSP is used for writing your content on the client-side. We can use this tag for displaying information on the client’s browser. The JSP Expression tag transforms the code into an expression statement that converts into a value in the form of a string object and inserts into the implicit output object.
Syntax: JSP tag
Difference between Scriptlet Tag and Expression Tag
- In the Scriptlet tag, it’s Evaluated a Java expression. Does not display any result in the HTML produced. Variables are declared to have only local scope, so cannot be accessed from elsewhere in the .jsp. but in Expression Tag it’s Evaluates a Java expression. Inserts the result (as a string) into the HTML in the .js
- We don’t need to write out.println in Expression tag for printing anything because these are converted into out.print() statement and insert it into the _jspService(-, -) of the servlet class by the container.
Output Using expression tag:
Let us take one more example.
Here we are creating an HTML file to take the username from user.save this file as index.html
Here we are creating A jsp file names as Geeks.jsp