• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Simple EL code is not working

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All

I am trying to write EL program. Could any of you please help me to get the output? I am expecting the value zero to be displayed. Do I need to import any jars?

<html>
<body>



Integer Testing
<%! int a = 0; %>



Value of a: ${a}
</body>
</html>


Result
Integer Testing

Value of a:
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The EL knows nothing of scripting variables. The EL works with scoped variables.

This is not surprising as the JSTL and EL is mean to supplant the use of scripting in JSPs. not to work with it.
 
Sangeetha Raja
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok. Thank you.
 
Sangeetha Raja
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all

Again one more question/doubt.

I am trying to write a EL program wiht arithmetic expression.

<HTML>
<HEAD>
<TITLE>EL Testing</TITLE>
</HEAD>
<BODY>
<H3>Fill-out-form</H3>


<FORM action="ELSample.jsp" method="GET">
<input type="text" name="A">
<input type="text" name="B">
<input type="submit" value="Submit Name">
</FORM>





The A is: ${param.A}



The B is: ${param.B}





Integer Testing



The Sum is: ${param.B} + ${param.A}
</BODY>
</HTML>


Result:

The A is: 2

The B is: 3



Integer Testing

The Sum is: 3 + 2

After updating the integers in the text boxes once i click submit button, i am getting the above result.

I understand that A & B are string variables , getting concatenated. How to do summation with EL. Can any one of you help me on this?

 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

The Sum is: ${param.B} + ${param.A}


How could it possibly know that these are suppoed to be related? They are two entirely separate expressions, each to be evaluated separately.

Think for a moment -- how could you tell the JSP translator that this is intended to be a single expression?
 
Sangeetha Raja
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hey.. i got

The Sum is: ${param.B + param.A}


Thank you...

Can you please provide me some link where i can find EL related materials and JSTL.. i have some but not that much informative....
 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sangeetha Raja wrote:Can you please provide me some link



www.google.com
 
Sangeetha Raja
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Links to the specs can be found in the FAQ.
 
Sangeetha Raja
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you!!!


I am trying to access java bean from Jsp with EL.

In ELTest1.html; I am getting 2 values



I have Person.java with 2 attributes String name; private Dog dName; (along with getter, setter) Also Dog.java with attribute String dogName; (along with getter, setter)



Person.java


In Servlet, ELTest1Servlet I am assigning the values to bean and forwarding to JSP;


In Jsp, ELTest.jsp: I am trying to display the bean values...



I am getting the error,
[2/5/09 22:50:29:920 EST] 00000028 ServletWrappe E SRVE0068E: Could not invoke the service() method on servlet /ELTest.jsp. Exception thrown : javax.servlet.ServletException: Unable to find a value for "dName" in object of class "foo.Person" using operator "."[/b][/b]

Anything wrong in my code? Pleae anyone of you help me to fix this.

 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please be sure to use code tags when posting code to the forums. Unformatted code is extremely hard to read and many people that might be able to help you will just move along to posts that are easier to read. Please read this for more information.

You can go back and change your post to add code tags by clicking the button on your post.

 
Sangeetha Raja
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you. I updated.
 
Ranch Hand
Posts: 1374
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Sangeetha,
Can you please show us your complete servlet? and both java bean classes?
 
Vikas Kapoor
Ranch Hand
Posts: 1374
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Duplication of above post.
Please delete this. Shouldn't we have control over our post atleast?
 
Sangeetha Raja
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i updated the java and servlet classes
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You should avoid property names which have a capital letter as the second character. I ran into the same problem when I tried to use "eMailAddress" as a property name. Something about the way the JavaBean rules change that into a method name (which I forget the exact problem now).
 
Vikas Kapoor
Ranch Hand
Posts: 1374
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not sure but, try putting nullary(no arg) constructor in both beans.This is one of few JavaBean conventions
I guess you use HFSJ. you can also cross check with the code they have provided.
 
Sangeetha Raja
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
its working if change the Caps to small..

I not yet tried with const....


Thanks a lot..
 
Sangeetha Raja
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The no arg constructor is not fixing the issue.

Thanks
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you change the property names to be more appropriate?

Even without the JavaBean standards, why would you use a name like getDName() instead of getDogName()? There is no need to "freeze dry" names like this. It's needless obfuscation.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic