Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Servlet-Interview-Questions servlet redirect problem help needed
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


animesh
servlet redirect problem help needed
0 Answer(s)      3 years and a month ago
Posted in : Servlet Interview Questions


package p;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class Ser extends HttpServlet{
protected void doGet(HttpServletRequest req, HttpServletResponse resp)throws ServletException, IOException {

String location= null;
if(1<2){
location="/j1.jsp";
RequestDispatcher re=getServletContext().getRequestDispatcâ?¦
re.forward(req, resp);

}
location="/j2.jsp";
RequestDispatcher re=getServletContext().getRequestDispatcâ?¦
re.forward(req, resp);

}
}
this servlet is calling by a jsp..there is no problem,in this servlet the if condition always getting true coz 1<2...so the programme counter goes through the loop...and when the counter executes the line re.forward(req, resp);..it it redirect to jsp name j1....(as i knew when ever re.forward(req, resp); is execute the counter will move to the last location which is stored in string obj...but this is not happening coz after executing the re.forward(req, resp); inside the if loop it comes out and also execute the last portion of the code...and giving error 

i thought re.forward(req, resp); works like return means jumps to the response ...so rest of the code will not be executed

if any any one knows plz tell me what happens when the first re.forward(req, resp); executes...and what whappen when the last one also execute

ERROR

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

java.lang.IllegalStateException: Cannot forward after response has been committed
p.Ser.doGet(Ser.java:23)
javax.servlet.http.HttpServlet.servicâ?¦
javax.servlet.http.HttpServlet.servicâ?¦
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.13 logs.

Advertisement
View Answers

Related Tutorials/Questions & Answers:
servlet redirect problem help needed
servlet redirect problem help needed  package p; import...=getServletContext().getRequestDispatcâ?¦ re.forward(req, resp); } } this servlet is calling by a jsp..there is no problem,in this servlet the if condition always
servlet redirect problem help needed
servlet redirect problem help needed  package p; import...=getServletContext().getRequestDispatcâ?¦ re.forward(req, resp); } } this servlet is calling by a jsp..there is no problem,in this servlet the if condition always
Advertisements
Help needed in JSP
Help needed in JSP  Hi .. I want to Update the multiple values of database using checkboxes and want to set the session for selected checkboxes..? please answer if any one knows as soon as possible
Redirect from servlet to servlet
Redirect from servlet to servlet  I want to insert data from Text box... to redirectServlet , and from this servlet I want to again forward my page to insertServlet(i.e... or wex.xml needs to be mapped properly . Can anyone help please Its urgent
redirect to multiple links from servlet
redirect to multiple links from servlet  hello , In my servlet page... the output in browser,i need to redirect to another link like the above line. i want redirect to multiple links simultaneously. anyone help me out
help Needed with requirements
help Needed with requirements  Following are my requirements : * Maintain a student database *Based on a student's test results ,reports should be generated so as to project details such as a students weakness in a particular
Java help needed
Java help needed  Create a web application that will allow a user... as needed by the number of characters of the chosen word. 2. Add 4 buttons or menu options: One for accessing help using the program, one for adding new words, one
Code Help Needed
Code Help Needed  I am trying to help a buddy of mine with this program and I can't seem to figure it out. I am still working on it but any help...[test]); line. Again thank you for any help. import java.util.*; import
urgent help needed!!!!
....please help me.... 1)state.jsp: <%@page import="java.sql.*"%>
urgent help needed!!!!
access country and state....please help me.... 1)state.jsp: <%@page import
help needed for a program - Java Beginners
help needed for a program   i am having trouble understanding on what to code, so can some 1 help me out here. thanks in advance. Part I Write, compile and execute a Java program that displays the following prompts
send redirect in JSP - JSP-Servlet
send redirect in JSP   How can I include a message i.e "redirected to this page because blah blah" in the send redirect page?  Hi friend, Please specify your problem the message print on the redirect to the next
help needed - Java Interview Questions
help needed  What are the new features added in jdk 1.5?  Hi friend, The following were the new features added in java 1.5.... * Autoboxing/unboxing ------------------------- This link will help you
look up values help needed
look up values help needed  Hi, I have a table that returns rows with a total weight (say 212.5 for example). I have another look up table that has... of 2.55 as 212.5kgs is between 195.5 and 220.5 can anyone help how I can do
PHP help needed - Development process
PHP help needed  This is my code that I am using for search engine, can any body answer how to cheange the code if I want limited and per page result display??? code Career Search result Yami says <?php
Help needed for Form Validation please help!
Help needed for Form Validation please help!  I have created a page which has login as well as Signup fields. I validated the login part by using jsp.../password combination . Problem arises while validating the Sign up part as after
Help needed for J2me and PHP - Development process
Help needed for J2me and PHP  Hello Sir I am a degree student. I have a small CRM application using J2me and PHP. I want to do cryptography using... but could not get result. I will appreciate your help. Regards
urgent help needed in JDBC AND JAVA GUI - JDBC
urgent help needed in JDBC AND JAVA GUI  my application allows... want any one to help me convert from scanner to java GUI for this code...(); } } // thanks for any help rendered   Hi Friend, Try the following code
Servlet Response Send Redirect - JSP-Servlet
Servlet Response Send Redirect  Hi, Thank you for your previous... value to the next jsp? 2. I have a servlet that saves patient data from..., I've catered to them by using JOptionPaneShowMessageDialogue in my servlet
validating username and password in servlet and redirect to login page with error message if not valid
validating username and password in servlet and redirect to login page... and password in my servlet against database and if not valid want to display error message saying "Invalid username and password" in my login page. please help
Java Servlet Problem - JSP-Servlet
, but in the attributeReplaced() method, i want to perform a redirect to another servlet... method. Please help!!  Hi friend, Please explain problem...Java Servlet Problem  I have a servlet class that implemets
CAN ANYONE SOLVE THIS FOR ME. URGENT HELP NEEDED. PLEASE HELP
CAN ANYONE SOLVE THIS FOR ME. URGENT HELP NEEDED. PLEASE HELP   The Task Write a class whose objects will represent students. The class should have three fields for representing a studentâ??s
CAN ANYONE SOLVE THIS FOR ME. URGENT HELP NEEDED. PLEASE HELP
CAN ANYONE SOLVE THIS FOR ME. URGENT HELP NEEDED. PLEASE HELP   Write a class whose objects will represent students.The class should have three fields for representing a studentââ?¬â?¢s name, this studentââ?¬â?¢s
Help needed on java standalone app and default browser interaction.
Help needed on java standalone app and default browser interaction.  Hi Developers and tutors, Is anyone able to guide on how am i able to extract...? Platform Windows Browser IE7 Any from of help would be deeply apperciated
Servlet problem
connectivity code it works but problem is with servlet page. My servlet code...Servlet problem  Hello, I am very shocked about this mysterious problem from last three month and now i hope rose india developers
please help me to this problem..
please help me to this problem..  i wrote a program like keyboard and i used [JTextFiled] means that just you can write inside the program (i.e inside the JTextField) but i want to make this program to let me write where i
servlet problem
servlet problem  wheni m deploying an servlet application im getting trouble context [/filename] startup failed due to previous error in tomcat 6.0.
help me to solve this problem..
help me to solve this problem..  Given below is a class definition for Book. Type and compile the class, and answer the following questions: class Book { String title; //bookâ??s title double price; //bookâ??s price
Further advice needed on my last question - JSP-Servlet
Further advice needed on my last question  Dear Experts, I refer to your last solution regarding my matching codes. After I tried out your... much for your help and patience.  Hi Friend, We have modified your
PLEASE HELP CAPTCHA PROBLEM
PLEASE HELP CAPTCHA PROBLEM  how can i make the captcha refresh autometically ???? please help this is <%@ Page Language="C#" %> <%@ Import Namespace="System.Drawing"%> <%@ Import Namespace
Send Redirect in Servlet
Send Redirect in Servlet     ... entered by the user is correct then the servlet will redirect the request... of our servlet, then there we should use sendRedirect() method.  In send
Advertisements
 

 

 

DMCA.com