• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

can we write methods inside a jsp

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
Can we write methods inside a jsp?
 
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:

 
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.
 
Marshal
Posts: 67279
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • 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
Marshal
Posts: 67279
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • 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
Marshal
Posts: 67279
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • 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
 
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 .
 
Ranch Hand
Posts: 494
Eclipse IDE Postgres Database Java
  • 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..
 
I would challenge you to a battle of wits, but I see you are unarmed - shakespear. Unarmed tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!