• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

When you are using EL, do we HAVE to explictly write servlet code?

 
Swagato Bhatta
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you are using EL, do we HAVE to have servlets?


I mean is it possible to go from HTML page directly to jsp page that has EL and get things done without having to EXPLICTLY write a single line of servlet code, scripting or Standard Actions?

I mean. I wish to go from a form of a HTML page directly to jsp page. That I think can be done. In the JSP page, I do not want any scriptings, Standard actions or do not want to write any servlets. I just want EL. And just print the value from the form. Is that possible?

Let us say we have the following index file (index.jsp) that takes data from form and passes it via post to chosing.jsp

Now let us take a look at the following abstract Person.java class


And Employee.java class


And employeeCar.java class



In chosing I wish to display the value of car name , empID and name. How do I do that without using scripting, directive, servlet...But just wish to use only EL? Possible?
I tried the following.. but doesnt work!

 
Ankit Garg
Sheriff
Posts: 9578
33
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes it is definitely possible. EL is just a way to access scoped attributes and other stuff. You can get request parameters through EL, or access bean style properties on different objects like ${pageContext.request.contextPath} to get the context path. You don't need any servlet code for all these. You can add scoped attributes using jsp:useBean tag, so you don't need to use any servlet for those too...
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Swagato Bhatta wrote:When you are using EL, do we HAVE to have servlets?

As Ankit said , not required . but I suggest you to use servlet , you *set* something in servlet . and read(get) in jsp using EL(read only)

Swagato Bhatta wrote:I mean is it possible to go from HTML page directly to jsp page that has EL


why you want to do this? . I guess , this is for learning purpose
 
Swagato Bhatta
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Seetharaman Venkatasamy wrote:
Swagato Bhatta wrote:When you are using EL, do we HAVE to have servlets?

As Ankit said , not required . but I suggest you to use servlet , you *set* something in servlet . and read(get) in jsp using EL(read only)

Swagato Bhatta wrote:I mean is it possible to go from HTML page directly to jsp page that has EL


why you want to do this? . I guess , this is for learning purpose


You are right. Just learning curve...

And thanks everyone

Page 382 (of Bert's book) has the answer

Following the code.. if ever anyone comes across this forum post :-)

 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Swagato Bhatta wrote: thanks everyone


 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic