Two Laptop Bag*
The moose likes Servlets and the fly likes urgent : Redirecting html page thru servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "urgent : Redirecting html page thru servlet" Watch "urgent : Redirecting html page thru servlet" New topic
Author

urgent : Redirecting html page thru servlet

Anupama Rao
Greenhorn

Joined: Aug 04, 2000
Posts: 13
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

Joined: Oct 19, 2000
Posts: 75
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


Have a wonderful day and wish u success<p>S Chandra Mohan<br />sc_mohan_us@yahoo.com
Anupama Rao
Greenhorn

Joined: Aug 04, 2000
Posts: 13
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

Joined: Oct 19, 2000
Posts: 75
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

Joined: Sep 15, 2000
Posts: 66
Hi Anupama,
Can u please post the few lines of code where u r using sendRedirect method.

Loke.
Anupama Rao
Greenhorn

Joined: Aug 04, 2000
Posts: 13
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

Joined: Oct 19, 2000
Posts: 75
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

Joined: Oct 19, 2000
Posts: 75
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

Joined: Sep 15, 2000
Posts: 66
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: urgent : Redirecting html page thru servlet
 
Similar Threads
Difference- servlet and jsp
Effects of pressing the Browser's Stop to the Servlet
How to print html page from servlet using Jrun?
servlet redirect to html page that called it
How to print html page from servlet using Jrun?