Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

urgent : Redirecting html page thru servlet

 
Anupama Rao
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
we have designed a form whose details are taken to a database thru a servlet and an acknowledgement which is html page should be redirected back thru the same servlet.but unfortunately it is opening in a new window even if we have not specified any targets.why is this happening. can anybody help??
 
S Chandra Mohan
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Anupama,
Ur problem is not much clear.
Normally we give acknowledgement message in new page which will open in the same window and we dont face such problem.
Have u written the codings in doGet & doPost?
please specify
regards
Mohan

 
Anupama Rao
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mohan,
Let me be more clear on this. The flow goes like this.
1.Data is entered in the html form.
2.On submit, the servlet is activated. We have used the doPost method in the servlet to take the data into the database.
3.The data is going to the database.
4. Once the data is inserted, the servlet is redirecting an acknowledment.html page in a new window.
The problem is, we have used the same logical flow for other applications. We were getting the confirmation in the same window. Now, in the current application, the confirmation is shown but not in the same window. Can this be expalined as to why this is happening even if we have not sepcified any target? If I am not wrong, there is no feasibility in the sendRedirect() to set the target.
I hope this is clear. Please answer back.
Regards
Anupama Rao
 
S Chandra Mohan
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anupama,
Why do u use sendredirect for confirmation?
U can do this by deploying a html directly from the same servlet.
It will be more easier.
Or u send the coding to sc_mohan_us@yahoo.com or put it in this pageitself.
I will try my level best with it.
regards
S Chandra Mohan
 
lokesh reddy
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Anupama,
Can u please post the few lines of code where u r using sendRedirect method.

Loke.
 
Anupama Rao
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, ChandraMohan and Loke.
Thanks for this response. I am sending the pseudocode. The idea of generating the HTML thru the servlet seems to be an option that can be looked for.
But do suggest me on sendRedirect() too.
Thanks for this.
import sattements;
class abcd extends HttpServlet
{
variables;
public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
{
try{
Driver Manager;
Statement Objects;
Connection Object;
Data Insertion;
}catch(Exception e){}
String name="Confirmation.html";
res.sendRedirect(name);
}
}
 
S Chandra Mohan
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no error in ur codeing upto my knowledge.
But ur actual codeing may have some minute mistake.
try for html direct deployment instead of redirect.
Regards
S Chandramohan
 
S Chandra Mohan
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no error in ur codeing upto my knowledge.
But ur actual codeing may have some minute mistake.
try for html direct deployment instead of redirect.
Regards
S Chandramohan
 
lokesh reddy
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HiAnupama,
There is nothing wrong with your code. As Chandra said, there may be some internal problem with your program.
I tried it thrice, but i am getting the result in the same window.
If possible check ur code once again.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic