Home Answers Viewqa JSP-Servlet Servlet Redirecting

 
 


AmanDeep
Servlet Redirecting
1 Answer(s)      4 years and 7 months ago
Posted in : JSP-Servlet

View Answers

October 18, 2008 at 12:18 PM


Hi friend,


Do check and correct errors in your code and we explain step wise and plz remember it.

-------------------------------------------------------------------------
1.Changes response.sendRedirect("ValidUser") replace with
res.sendRedirect("ValidUser");
-------------------------------------------------------------------------

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;


public class Slogin extends HttpServlet implements Servlet
{

public void doPost(HttpServletRequest req, HttpServletResponse res)throws IOException, ServletException
{

res.setContentType("html/text");
PrintWriter pw = res.getWriter();

String id = req.getParameter("id");
String pwd = req.getParameter("pwd");

//Redirect call to another url
res.sendRedirect("ValidUser");

}

}
}

///////////////////////////////////////////////////////////////////////////

2.In "ValidUser.java" :

----------------------------------------------------
Changes doPost() replace with doGet() method
----------------------------------------------------

import java.io.*;
import java.io.IOException;
import javax.servlet.*;
import javax.servlet.http.*;


public class ValidUser extends HttpServlet implements Servlet
{

public ValidUser()
{
super();
}

public void doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException
{
PrintWriter pw = response.getWriter();
pw.println("Welcome to roseindia.net<br>");
pw.println("how are you");
}
}

//////////////////////////////////////////////////////////////////////////

3 "web.xml"
--------------------------------------------------------------------------
You have not servlet mapping for "ValidUser.java"
--------------------------------------------------------------------------

<web-app>
<servlet-mapping>
<servlet-name>any</servlet-name>
<url-pattern>/Enter</url-pattern>
</servlet-mapping>

<servlet>
<servlet-name>validuser</servlet-name>
<servlet-class>ValidUser</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>validuser</servlet-name>
<url-pattern>/ValidUser</url-pattern>
</servlet-mapping>

</web-app>

For more information on Servlet visit to :

http://www.roseindia.net/servlets/

Thanks









Related Pages:
Servlet Redirecting - JSP-Servlet
Servlet Redirecting  Hi I have made a main page with User name...*; public class Slogin extends HttpServlet implements Servlet { public void...*; public class ValidUser extends HttpServlet implements Servlet
Servlet Redirecting - JSP-Servlet
Servlet Redirecting  Hi I have made a main page with User name and password parameters, and when i try to direct it to the login page using sendRedirect("") method on clicking a button instead fo directing it prompts a save
Redirecting the output of an expression to a variable - JSP-Servlet
Redirecting the output of an expression to a variable  I want to redirect the output of to a variable defined in variable.jsp. What is the syntax for this?   Hi Friend, Use the following code in your 'variable.jsp
verfication of user login and then redirecting it to user defined page
,the html page calls teh servlet..but..the servlet.is not redirecting to a user defined...verfication of user login and then redirecting it to user defined page  hi, i have a login page that..calls the servlet..and i have used redirect
Redirecting and forwarding to views
In this section, you will learn about redirecting and forwarding views through prefixes
Redirecting the console output into a file in Java
Redirecting the console output into a file in Java  Hi, i coded a program that read specific lines from a text file. It's working well. Now i want to redirect the output of the console to a text file. i used your tutorial
Servlet Session Tracking - JSP-Servlet
Servlet Session Tracking  Hi I have made a main page called SessionTest with User name and password parameters, and i wand to track the name to a new Servlet of name: SessionNew by URL Redirecting method, but instead fo giving
redirecting a login authenticated form to a form to be displayed on the same page from where the login authentication has taken place.
redirecting a login authenticated form to a form to be displayed on the same page from where the login authentication has taken place.  I am successfully able to create a session on successful login, but I want to display
PHP Redirection Redirecting URL Tutorial, PHP Redirecting URL
In this tutorial I would like to describe three possible ways of redirecting a visitor to any other URL. Also you can read here PHP, HTML and JavaScript... in this function. Just for redirecting you can use: header("Location: http
JSP - JSP-Servlet
; > and i am redirecting to another page.. while i am loading again
Servlet
Servlet  What is Servlet
Servlet
Servlet  how to navigate one servlet page to another servlet page
can we write a method in JSP - JSP-Servlet
can we write a method in JSP  Hi All, In my web application I want to call another second jsp file. I can do it by redirecting my first jsp file... for execution) of first jsp file by redirecting second page to the first page. I can call
servlet
servlet  How many times the servlet is accessed
servlet
servlet  is there any way to include pdf's in servlet
servlet
servlet  what are the methods and interfaces in the servlet api ?   Servlet Tutorials
servlet
servlet  what are the all necessary configuration to run a servlet
servlet
servlet  how to interact with a servlet from a swing program
servlet
servlet  I designed 1 html form & a servlet but when I click on form I don't get output of servlet Please help
servlet
servlet  I designed 1 html form & a servlet but when I click on form I don't get output of servlet Please help
Servlet
override Service method in the servlet when you extend GenericServlet to create servlet as it is mandatory to override it. But, when you extend HttpServlet to create a servlet then you can't override service method as there is a need to override
Servlet
Servlet  What must be implemented by all Servlets?    The Servlet Interface must be implemented by all servlets
servlet
servlet  i want a program for counting the no of times the servlet has been invoked
servlet
servlet  how to create a login form using servlet using submit,edit delete button
servlet
servlet  dear sir servlet and html not run on eclips plz help me
servlet
servlet  can i stoar record in variable which selected from table in servlet
servlet
of the Servlet API. It contains the classes necessary for a standard, protocol-independent servlet. Every servlet must implement the Servlet interface in one
Servlet
Servlet  I want to know the steps to write a simple servlet program... .   Hello Friend, Follow these steps: Put servlet-api.jar inside the lib folder of apache tomcat. 1)create a servlet. import java.io.*; import
Servlet
Servlet   Why is Servlet so popular?   Because servlets are platform-independent Java classes that are compiled to platform-neutral byte code that can be loaded dynamically into and run by a Java technology-enabled Web
servlet
servlet  i want to use servlet application on my web page then what should i do. I have already webspace.   Hi Friend, Please visit the following link: Servlet Tutorials Thanks
servlet
servlet  how to read a file from different folder using filereader in servlet   Hello Friend, Please visit the following link: http://www.roseindia.net/servlets/servlet-read-file.shtml Here you will get an useful
Servlet
Servlet  Can a user defined function be included in a servlet? I need information regarding servlet syntax and not JSP.   Yes, you can create user defined function in Servlets. Have a look at the following link: http
Servlet
Servlet  Hi, Can any one please expalin me below topics SERVLET ENGINE 2.WHY SUPER.INIT(); Thanks alot in advance!! Regards: Akash
Send Redirect in Servlet
Send Redirect in Servlet      ... servlet, then there we should use sendRedirect() method.  In send Redirect... decides whether the concerned servlet can handle the request or not.  
servlet
servlet   Dear Deepak, is it compulsary to write the sevice() becoz i ve seen some example which does not ve sevice()..is it tue? plz replay me with thanks praveen
servlet
servlet  I want a fully readymade project on online voting system with code in java servlet and database backend as msaccess.can u plz send me as soon as possible
servlet
servlet  plz can anyone give me the link of javax library jar file. i badly need that. thanks in advance   Please visit the following link: Download Servlet API
Servlet
the same error <web-app> <servlet> <servlet-name>InsertServlet</servlet-name> <servlet-class>InsertServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>
servlet
servlet file which prints out the user's inputs. I need to use the post method to pass the data from html to the java servlet and also use both doGet and doPost methods in the servlet. I think, but unfortunately I have a terrible teacher
SERVLET
to the servlet and if the user id is correct then a new page will be displayed with his... pass to the servlet and all the fields brlongs to that id will be appear... will be done by using jsp and servlet... Plz help me,im really tensed...........  
servlet
servlet  hi sir,this is ashok.i installed tomcat 6.0 and jdk-150.i checked the server it's working but when execute servlet program for the .class file it shows the errors javax.servlet is not exist.what can i do,please tell me
servlet
to servlet. So, if anyone can help me so I can see how to connect the two I would
servlet
servlet  How do we define an application level scope for servlet?   Application scope uses a single namespace, which means all your pages should be careful not to duplicate the names of application scope objects
servlet
servlet  how to jsp integer are type cast int servlet page   Hi Friend, Try the following code: 1)form.jsp: <form method="post" action="../Data"> Enter Number:<input type="text" name="num" > <input
servlet
servlet   try { con=DaoPack.createConnection(); } catch(Exception e) { e.printStackTrace(); } if(request.getParameter("addproduct")!=null) { ProductBean bean=new ProductBean
servlet
servlet   try { con=DaoPack.createConnection(); } catch(Exception e) { e.printStackTrace(); } if(request.getParameter("addproduct")!=null) { ProductBean bean=new ProductBean
servlet
com.ilp.tsi.pm.services.StockService; /** * Servlet implementation class AddServlet1 */ //Servlet for Adding the stock public class AddStockServlet extends...; import com.ilp.tsi.utils.*; /** * Servlet implementation class Changepwd
servlet
); } } } this is the code for .java servlet am able to run sucessful but when i give wrong
servlet
com.ilp.tsi.um.bean.BankBean; import com.ilp.tsi.um.service.BankService; /** * Servlet

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.