Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Basic question about jsp expressions

Status
Not open for further replies.

JProg

Programmer
Apr 4, 2002
88
JP

Hi Everyone,

I am still trying to get a grip of writing JSP pages and have a couple of simple questions:

From what I have read it is possible to include any evaluator normally found in Java within a jsp expression.

e.g.: <%= 2 + 8 %>

I figure that this should evaluate to 10.

If I am correct then I also guess that the result 10 is actually converted to a string and then written to the output (web page presumably).

Now if I am correct so far is it viable to do the following?

e.g.: <%= 2 + beanName.getBeanProperty() %>

And if the bean property happens to be an integer value of 8, then again 10 will be output onto the web page.

If anybody could let me know if I am on the right track or not it will be greatly appreciated.

Thanks

Regards

David




 
When the JSP parser/compiler transforms your JSP to a servlet on load, the line :

<%= 2 + beanName.getBeanProperty() %>

will become :

out.println(2 + beanName.getBeanProperty());

So if beanName.getBeanProperty() returns an int, you'll be fine ...

You can see what your JSP's look like in .java form by lokking in the work directory of your servlet container (ie tomcat). If your JSP is named "mypage.jsp" the .java file will be something like 0_mypage_jsp.java or similar.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top