wood burning stoves 2.0*
The moose likes JSP and the fly likes Redirecting from JSP to Servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Redirecting from JSP to Servlet" Watch "Redirecting from JSP to Servlet" New topic
Author

Redirecting from JSP to Servlet

Jay Shukla
Ranch Hand

Joined: Jun 08, 2008
Posts: 214
Hi I'm new to JSP.

Can anyone please let me know how to redirect / forward JSP page to servlet without any response/input to the user.

I Mean that when user access input.jsp it should be redirected to a Servlet.

Thanks in Advance.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61106
    
  66

Jay Shukla wrote:I Mean that when user access input.jsp it should be redirected to a Servlet.

Since the purpose of a JSP is to present a view to the user, under what scenario would this be appropriate? It's a big red flag that you may have some serious design problems with your application.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Jay Shukla
Ranch Hand

Joined: Jun 08, 2008
Posts: 214
Hi Actaully when user access my application by default it'll call index.jsp. because i don't user to access direct URI of my application so when user access my application then it'll redirected to one servlet where it'll run java code and redirect to one more jsp.

So for this purpose could you please let me know the solution for this?


Thanks.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61106
    
  66

You can redefine what default resource they visit by setting it in the welcome-file-list of the deployment descriptor. It's doesn't have to be index.jsp -- that's just the default.

That said, you could use <jsp:forward> to forward to a new resource, or redirect in any number of ways. The most straight-forward being to use HTML META tags to specify the redirect.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Redirecting from JSP to Servlet