Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to write ActionServlet which should act like a controller?

 
Sandhya Deekonda
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I have a web application in which i've a jsp like One.jsp.In that jsp i've a form,when ui submit it should go to another jsp.But in the action field of the first jsp,I shouldn't mention the second jsp name.I should mention some thing like "welcome".When i submit the form, it should go to a servlet which sends the form to the second jsp,that means the servlet acts like a controller which sends the request to the corresponding jsp.How can i do that? Can anyone help me??
Thanks,
Sandhya.
[ January 17, 2007: Message edited by: Bear Bibeault ]
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should read up on request dispatchers:
http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/RequestDispatcher.html

Also, in my signature, there is a link to the servlet spec, in it there is a section on servlet-mappings.

What you want to do can be done with a controller or it can be done by giving your JSP a servlet entry and a servlet-mapping with the url-pattern of your choice.
 
Sandhya Deekonda
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my first jsp,when form is submitted the server checks for the requested url in the web.xml .If it finds that url it goes to that particular jsp or servlet.This shouldn't happen.It should go to some other servlet,that servlet should point to some other configuratopn file like config.xml.From there it should go to the requested servlet.How can i do that?
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why don't you show us what you've got so far?
Have you read the links that I posted?
 
Sandhya Deekonda
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ya I went through the links which you posted.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic