Bug 37933 - Bugs in Tomcat
Summary: Bugs in Tomcat
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 5
Classification: Unclassified
Component: Servlet & JSP API (show other bugs)
Version: 5.0.0
Hardware: PC Windows 2000
: P1 major (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-12-16 07:00 UTC by manokaran
Modified: 2006-02-27 11:39 UTC (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description manokaran 2005-12-16 07:00:20 UTC
Hi,
I am manokaran.I wrote a program in tomcat using eclipse IDE. 

The code is as follows:

1.>This is a Bean:
package MMM;

public class Bean {
	private String name;
	public void SetName(String s)
	{this.name=s;
	}
	public String getName()
	{
		return name;
	}

}

 2.>This is a Servlet class:
package MMM;

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 Serv  extends HttpServlet{

	public void doGet(HttpServletRequest request,HttpServletResponse response)
throws ServletException,IOException
	{
		Bean bean=new Bean();
		bean.SetName("manokaran");
		request.setAttribute("mano",bean);
		RequestDispatcher rd=request.getRequestDispatcher("india.jsp");
		rd.forward(request,response);
	}
}
3.This is web.xml file:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>
<servlet>
<servlet-name>mano</servlet-name>
<servlet-class>MMM.Serv</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>mano</servlet-name>
<url-pattern>/manokara.do</url-pattern>
</servlet-mapping>
</web-app>

4.>This is Index.html file:
<html>
<form action=manokara.do>
<input type=submit>
</form>
</html>
 
5.>This is a JSP file:
<jsp:useBean id="mano1" class="MMM.Bean" scope="request" />
<jsp:getProperty name="mano" property="name"/>

Report:

      The setAttribute, Jsp UseBean ID  and getProperty name must be same.
this is the correct procedure. this format was working well in tomcat and all
web,application servers.  
      But the values set by me were : setAttribute("mano",ss),getProperty
name="mano"      
useBean id="mano1". Observe that the useBean id is set different. 
     Hence logically, this must not work. But in my case it is working in
TOMCAT. The same code is not working in WEBLOGIC.
Comment 1 william.barker 2005-12-18 04:43:25 UTC
Yeah, well, it doesn't look like the spec will accept a previously defined 
Request-Attribute here (at least with the 'recommended' action), so you have a 
point.

I'll have to look into it more to see if it's reasonable to do the compile-
time 'recommended' action, or if we will just have to do it at runtime.  In 
anycase, it won't be pretty :(.  



Comment 2 william.barker 2005-12-19 01:53:00 UTC
This is fixed now in the SVN trunk, and will appear in 5.5.15.

The fix raises a runtime error in your test case.  I don't see how to do it at 
translation time, but I'm happy to be proven wrong :).
Comment 3 william.barker 2006-02-27 20:39:26 UTC
*** Bug 38797 has been marked as a duplicate of this bug. ***