About JSP Expression Language



Share on Google+Share on Google+

About JSP Expression Language
2 Answer(s)      9 years ago
Posted in : JSP-Servlet

Hi i am new to JSP i am now going through the basics of JSP..on the process i tried a simple JSp program... pls help me... Addition of Two Numbers JSP

View Answers

April 2, 2008 at 8:04 PM

Addition of Two Numbers JSP

Hi! Nice problem but you do not need to worry as you have made a very small mistake!
In your code you have defined the function in static format and anything, which is written in static, will print the value as it is given.

In your code you have written ?2 + 2 is $ {2 + 2}? in a body, so there is no chance of getting calculated value from it.

In JSP programming you can retrieve the value through Scriptlets <% %>.

Your program of Addition of two values in JSP would be as fellow:

JSP addition of two Numbers - Example Code

- - - - - - - - - - - - - - - - - - - - - - -
<%@ page language="java" import="java.util.*" %>
<h1>Hello World!</h1>
int i = 45;
int j = 30;
int Sum;
Sum = i + j;

out.println("The sum of " + i + " and " + j + " is =" + Sum); %>
- - - - - - - - - - - - - - - - - - - - - - -
You must be feeling much better now.... i guess

April 2, 2008 at 8:11 PM

Run the above given answer and i'm sure it'll work for you. if you want to go into deep of JSP Scriptlets just read the JSP Scriplet Tutorials here




Related Tutorials/Questions & Answers:
About JSP Expression Language - JSP-Servlet
About JSP Expression Language   Hi i am new to JSP i am now going through the basics of JSP..on the process i tried a simple JSp program... pls help me... Addition of Two Numbers JSP   Addition of Two Numbers JSPHi
Expression Language in JSP
Expression Language in JSP      ... application data stored in JavaBeans components. The jsp expression language allows... to include server state in the jsp page output. Expression Language (EL
JSF Expression Language(EL)
Expression Language(EL) In this section, you will get a brief description about Expression Language of JSF. Expression Language is used to access... support expression language methods of JSP. Expression language Literals
What is the difference between JSP expression language and scriptlets? - JSP-Servlet
What is the difference between JSP expression language and scriptlets?  Hi, I just want to ask what is the difference between JSP Expression Langauge and JSP scriptlets? Pls help me.   Hi friend
Expression Language execution in notepad
Expression Language execution in notepad  how to execute expression language in notepad for java i am using apache tomcat server4.0.
expression language array
expression language array  var test='${abc.myarray}'; //myarray is string array in bean //abc How to get the length of myarray? I tried test.length which does not work
Expression Language Basic Arithmetic
components. The jsp expression language allows a page author to access a bean using...Expression Language Basic Arithmetic          EL means the expression language
about a program in c language
about a program in c language   Write a program that inputs five different integers from the keyboard, then print the sum, the product, the smallest and the largest of these numbers. Use only single selection form of if statement
about regular expression - Java Beginners
about regular expression  Consider the grammar G: S -> ( L ) | a L -> L, S | S a) Eliminate the left-recursion from grammar G. b) Construct a recursive descent parser for G
cron expression - JSP-Servlet
cron expression  Hi, I need to create cron expression dynamically in java when the user gives the specifications like frequency, delay, daily , monthly etc.. from a jsp page. Please help me out ASAP. Regards, Pavani
Language' attribute of JSP page directive
'Language' attribute of JSP page directive In this Section , we will discuss about the "language" attribute of a JSP page & its use in JSP page. A directive element in a JSP page provides global information about
About jsp
About jsp  Read Excel data using JSP and update MySQL databse
About Java Programming Language
About Java Programming Language       Java is an Object oriented application programming language... language. Java programming language is useful for development of enterprise grade
About Jsp
About Jsp  Hello sir, I am developing online Quiz project in jsp using MySql Database. I want to know that How I will show Questions from database One by One on Same page and also want to calculate Result for the User
Redirecting the output of an expression to a variable - JSP-Servlet
Redirecting the output of an expression to a variable  I want to redirect the output of to a variable defined in variable.jsp. What is the syntax...' file: Create another jsp file 'get.jsp' to get the output: Thanks
Expression tag
Expression tag  Defined Expression tag in JSP ?   Expression tag is used to display output of any data on the generated page. The data... a scripting language expression which is evaluated, automatically converts data
Display "Hello JSP" using Jsp expression
Display "Hello JSP"  using Jsp expression In this section, We will simply output "Hello JSP"  in a web browser using Jsp expression. JSP expressions insert values directly into the output. The syntax
PHP Expression
PHP Expressions: In every language expression plays a vital role, in PHP whatever you write is an expression (almost anything). Anything has a value is an expression and this is the easiest way to define and understand expression
About jsp and Servlet - JSP-Servlet
About jsp and Servlet  Servlets are directly using java technologies. It is used in HTTP,FTP..etc, But Jsp only used in HTTP. Servlets are running fastly... Then why we moved from Servlet to JSP.. Pl Tell me the reasons
about jsb - JSP-Servlet
about jsb  after doing project using jsb iwant public to see it from my device (as server) what i do? need help   Hi friend...://www.roseindia.net/jsp/ Thanks
about hashmap - JSP-Servlet
about hashmap  hi.. i want suggestion in hashmap handling. in my program i have to pass parameters from different jsp pages and ve to store it. i ve used vector but its not recommended . thanks in advance
Question about JSP - JSP-Servlet
Question about JSP  Please tell me how to retrieve an image from SQL Server 2000 using JSP code.I know how to store the image as it stores in binary format. But i don't know hoe to retrieve
About MVC 2 architecture and jsp - JSP-Servlet
to the client request.But JSP is a scripting language flexible for web designers...About MVC 2 architecture and jsp  Sir, I want to know about MVC 2... is the need of servlets when jsp can perform all functionalities .  Hi
about player - JSP-Servlet
about player  hi i have a website in which, i want to play some video& audio files using jsp.so ,how to call the realplayer on to my website and play some video. if the user doesnot have a player , it should automatically
Extensible Stylesheet Language (XSL)
Extensible Stylesheet Language (XSL) is concerned about a family of languages: 1. XSL Transformations (XSLT) 2. XML Path Language (XPath) 3. XSL... is a language for transforming XML documents. XPath is an expression language
How to make session control using only JSP programming language
How to make session control using only JSP programming language  Could i do Controlling session using only JSP programming language without using anylanguage
Use of "ancestor" in XPath expression
Use of "ancestor" in XPath expression       As you learned about descendant axis in XPath expression in the previous example, this section will illustrate the use of ancestor
Null Expression Example
Null Expression Example       In this section, you will see the example of null expression in with JPQL (Java Persistence Query Language). In this example, we
Regular expression
Regular expression  how i write a regular expression for a pattern which present in between
Regular expression
Regular expression  I have the regular expression : var x=/(^\d+$)/ which allows only numbers. It does not accept character, decimals. However it accepts zero. I want an expression that takes numbers(no decimals)except zero
About tld files - JSP-Interview Questions
About tld files  What are tag library descriptor files & what... files are the XML document that contains information about the whole library and about each tag contained in the library. These files are used by a web container