File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Redirecting from JSP to Servlet

 
Jay Shukla
Ranch Hand
Posts: 214
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64182
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jay Shukla
Ranch Hand
Posts: 214
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64182
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic