• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Values from bean to a servlet

 
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
 
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
any exception or error you are gettin??
 
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
 
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.
 
Water! People swim in water! Even tiny ads swim in water:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic