This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
You can't, and you shouldn't. If you need the same code in servlets and JSPs move it to a Java class, maybe as a static method. Or even better, keep all code out of the JSP pages; they're not meant for doing computations. You can use backing beans, JSTL tags, or your own custom tags for that. [ November 13, 2007: Message edited by: Ulf Dittmer ]
Ping & DNS - updated with new look and Ping home screen widget
yes you are right you cannot access functions defined in jsp in servlet.if you want to then have to create separate class. since you cannot create object of servlet directly it is created by container and if you can't access function of 1 servlet into another servlet then how can you access from jsp page after all jsp pages are servlet.
The idea of combining JSP and Servlets is a good one, but its actually the exact reverse of what you thinking. I suggest you google the web for as much info as you can find on Servlets and the MVC model... it will get you going. Basically the servlet gets the request, it sticks stuff into a request or session bean, and then DISPATCHES the request off to the JSP page.
So servlets do the work, JSP's just diplay info... very powerful way of using a servlet container. Basicly you hava a worker bean or class that is moving between servlet and jsp page... so thats the connection between the two.