Advertisement

08.08.2005 at 08:38PM PDT, ID: 21520271
[x]
Attachment Details

Passing Parameter from a Servlet to other Servlets

Asked by edwbear1976a in Java Programming Language, Java Servlets

Tags: , , ,

Hi Experts I have 2  servlets :
LongOn.class
Form1.class
First one is for login in (user name and pwd), once is logged in  It should call  to other servlet that shows a simple form, well I want to pass the user name gotten  from the first servlet to the second servlet, cause  I have to save the   user name   in a database table (its part of the information of the form)

1.How can I set the parameter username in the first Servlet
2.How can I get the parameters username in the second Servlet
3. I use the following syntax in the Post Method to call the second servlet from the first servlet
ServletContext sc =getServletContext();
RequestDispatcher rd=sc.getRequestDispatcher("Form1.class");
                  try
                  {
                  rd.forward(req,res);      
                  }      
       
                  catch(IOException e)
                  {
                  System.out.println (e.getMessage());      
                  }      


but it shows an error message " java.lang.IllegalArgumentException  '/'  missing" , well so I put that character and then it showed other error message " /Form1.class resource is not available "
Well both servlets are located in the same directory (C:\jakarta-tomcat-5.0.28\webapps\ROOT\WEB-INF\classes)

ThanksStart Free Trial
 
 
[+][-]08.08.2005 at 10:44PM PDT, ID: 14630118

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]08.09.2005 at 01:30PM PDT, ID: 14636658

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Java Programming Language, Java Servlets
Tags: servlet, from, pass, parameter
Sign Up Now!
Solution Provided By: ngujja
Participating Experts: 2
Solution Grade: B
 
 
[+][-]08.10.2005 at 08:32PM PDT, ID: 14648768

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.11.2005 at 06:38AM PDT, ID: 14651272

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32