File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Values from bean to a servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Values from bean to a servlet" Watch "Values from bean to a servlet" New topic

Values from bean to a servlet

aliya sharma
Ranch Hand

Joined: Aug 11, 2004
Posts: 48
Hello I'm new to J2EE. I have a table called boxcontents that has 2 fields(part_no, content). I'm trying to search by part_no using MVC. I have 1 html page where user enters the part_no. Servlet then reads this part_no and forwrds it to java bean which performs a lookup based on the part_no. Servlet then reads the result and forwards it to a jsp that displays it. My problem is: i'm able to send the Parameter via servlet to java bean by:

this is my javabean

How do i read this result into a servlet and forward it to a JSP?. I would really appreciate it if anyone can point me to a right direction. THanks a lot.
aliya sharma
Ranch Hand

Joined: Aug 11, 2004
Posts: 48
this is my whole code:
servlet code:

bean code (class called

JSP code:

COuld someone please tell me what im doing wrong or point me to the right direction. THanks
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
any exception or error you are gettin??
Rahul kapoor

Joined: Sep 21, 2004
Posts: 16
Apparently your problem lies in the following code.

You have initialised BoxContent but not storing the results of findByPart(..) in box.

use box = BoxContent.findByPart(part_no);

and check.

BoxContent box = new BoxContent();BoxContent.findByPart(part_no);req.setAttribute("result", box);
aliya sharma
Ranch Hand

Joined: Aug 11, 2004
Posts: 48
i changed my controller code as:

Its still not working. WHen i enter a value in my html page and hit submit. It gives me a

Any ideas or leads...As, this is my first MVC project, i would appreciate any help. THanks
Senthil B Kumar
Ranch Hand

Joined: Feb 09, 2004
Posts: 160
Has your Controller Servlet been registered in you Server through a web descriptor (web.xml). I guess its not been registred.

Work like you don't need the money. Love like you've never been hated. Dance like nobody's watching. Sing like nobody's listening. Live like it's Heaven on Earth.
Currently I Reside Here WEBlog
I agree. Here's the link:
subject: Values from bean to a servlet
It's not a secret anymore!