File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Servlet call from index.jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Servlet call from index.jsp" Watch "Servlet call from index.jsp" New topic
Author

Servlet call from index.jsp

Yayathi Jayaraman
Greenhorn

Joined: Aug 10, 2012
Posts: 7
HI,
I called a servlet from index.jsp its successfully loaded, after creating a database and stored a value into bean need to redirect the same page to display the bean in index.jsp.
Can anyone tell me what to write in servlet init() method to redirect into index.jsp page

Thanks in advance.









G krishna kumar
Greenhorn

Joined: Oct 10, 2012
Posts: 14
use requestDispatcher to redirect to the same page i.e index.jsp in your servlet service()...
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60810
    
  65

Yayathi Jayaraman wrote:Can anyone tell me what to write in servlet init() method to redirect into index.jsp page

The init() method has nothing at all to do with servicing a request. This is not the place to do anything like that.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60810
    
  65

jagdeesh kumar wrote:use requestDispatcher to redirect to the same page i.e index.jsp in your servlet service()...

Nope. The RequestDispatcher is used to forward to a JSP. A redirect is accomplished via the sendRedirect() method.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Servlet call from index.jsp
 
Similar Threads
Using redirect from backing bean and getting IllegalStateException error
POSTing from servlet to JSP
problem in login
Servlet to html
Problems during struts application migration from weblogic 6.1 to weblogic 8.1