Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Values from bean to a servlet

 
aliya sharma
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this is my whole code:
servlet code:

bean code (class called BoxContent.java):


JSP code:


COuld someone please tell me what im doing wrong or point me to the right direction. THanks
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
any exception or error you are gettin??
 
Rahul kapoor
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
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
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Has your Controller Servlet been registered in you Server through a web descriptor (web.xml). I guess its not been registred.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic