This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Scriptless JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Scriptless JSP" Watch "Scriptless JSP" New topic

Scriptless JSP

Steve Jerome

Joined: Mar 03, 2007
Posts: 22
public void doPost(HttpServletRequest req,HttpServletResponse res)throws

Person p=new Person();
//PrintWriter pw=res.getWriter();
//Person p1=(Person)req.getAttribute("per");
RequestDispatcher view=req.getRequestDispatcher("result.jsp");
An error occurred at line: 3 in the jsp file: /result.jsp
Person cannot be resolved to a type
1: <html>
2: <body>
3: Person's name is<%Person p=(Person)request.getAttribute("per"); %>
4: <%=p.getName()%>
5: </body></html>

It's a program in page 345.when I run the servlet program alone it displays the name correctly.but if I pass the iformation to jsp file it's displaying the above server error.Person is a simple java class with getName(),setName() methods.can anyone help me out in this.
Christophe Verré

Joined: Nov 24, 2005
Posts: 14688

Person is in a package isn't it ? So you have to import the package, using the "import" attribute of the "page" directive. Or explicitly naming the package.
For example, if Person is in the "beans" package :

If Person is not in a package, put it in one ! Putting classes in the default package may give unpredictable results.

[My Blog]
All roads lead to JavaRanch
Steve Jerome

Joined: Mar 03, 2007
Posts: 22
Thanks Chris after putting my classes in package the code runs fine now.
[ July 14, 2007: Message edited by: Steve Jerome ]
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: Scriptless JSP
It's not a secret anymore!