• Post Reply Bookmark Topic Watch Topic
  • New Topic

can we write methods inside a jsp  RSS feed

 
ravi lingala
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
Can we write methods inside a jsp?
 
Charles 'King
Ranch Hand
Posts: 56
Eclipse IDE Postgres Database Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ravi lingala wrote:Hi All,
Can we write methods inside a jsp?


Why on earth would you want to do this? If there's a good reason, here's your answer:

 
Shakeel Shaik
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ofcouse you can.
http://www.roseindia.net/jsp/simple-jsp-example/jsp-methods.shtml
But you cannot access implicit variables in it. You have to pass the variables to the method.

i never faced such situation. do it only if you have a very valid reason.I cant even think of a scenario where this might be useful.
If you are faced with such a situation, you better think over your logic again. You will face more problems in the long run.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please take the time to choose the correct forum for your posts. This forum is for questions on Servlets. For more information, please read this.

This post has been moved to a more appropriate forum.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The time for mis-using JSPs in such manner is long past. Best accepted practices dictate that JSPs should be used for view generation and not for other types of uses. Scriptlets, including the scriptlet declarations necessary to create methods are discredited and should no longer be used. Modern techniques such as the JSTL, EL, EL functions and custom tags are what you should be exploring.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"shaks ss", please check your private messages for an important administrative matter.
 
ravi lingala
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks all for your responses.
Bear
From next time onwards I will post it in correct form only.Please Forgive me this time
 
tushar panda
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ravi lingala wrote:Can we write methods inside a jsp?


you can , but its an older way .
 
Leonardo Carreira
Ranch Hand
Posts: 494
Eclipse IDE Java Postgres Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, the best implementation is JSP only used for View from an integration..
People sometimes prefer to use the integration between..
JPA-EJB-Servlet-JSP
this is the integration standardized..
and sometimes, people use other integration...
and from all of that integrations, JSP only used for View..
which has main action to render/consume data from/to Controller..
the Controller in this integration case is Servlet..

Please correct me if i'm wrong...
Thanks..
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!