Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Servlets
Search Coderanch
Advance search
Google search
Register / Login
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
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Servlets
passing values from servlets to jsp page via request.getRequestDispatcher method
Vivek Kr Agrawal
Ranch Hand
Posts: 51
I like...
posted 11 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I am trying to fetch a bean object from database(which is working fine) in a
servlet
and passing it to a
jsp
page. My code in servlet is as:
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { Proposal_Create_Utility read = new Proposal_Create_Utility(); //utility class db connection ProposalBean bean = new ProposalBean(); //bean class bean = read.read_proposal_utility(request); //working fine checket by using println statements request.setAttribute("proposalId", bean.getProposalId()); request.setAttribute("vehicleId", bean.getVehicleId()); request.setAttribute("dateOfAccident",bean.getDateOfAccident()); request.setAttribute("amountClaimed", bean.getAmountClaimed()); request.setAttribute("typeOfLiability",bean.getTypeOfLiability()); request.getRequestDispatcher("/read_liability_proposal.jsp").forward(request, response); }
My read_liability_proposal.jsp page looks like
<table border="1"> <div> <tr> <td> Proposal Id </td> <td> <label id="proposalId" ><%= request.getParameter("proposalId") %></label> <br /> </td> </tr> <tr> <td> Vehicle Id </td> <td> <label id="vehicleId" ><%= (String)request.getParameter("vehicleId") %></label> <br /> </td> </tr> <tr> <td> Date of Accident </td> <td> <label id="dateOfAccident"><%= request.getParameter("dateOfAccident") %></label> </td> </tr> <tr> <td> Amount Claimed </td> <td> <label id="amountClaimed"><%=request.getParameter("amountClaimed") %> </label> </td> </tr> <tr> <td> Type </td> <td> <label id="typeOfLiability"><%=request.getParameter("typeOfLiability") %> </label> </td> </tr> </table>
I am getting null everywhere except for Proposal Id.
Vivek Agrawal
Bear Bibeault
Sheriff
Posts: 67746
173
I like...
posted 11 years ago
1
Number of slices to send:
Optional 'thank-you' note:
Send
Point #1:
You should
be using the EL in your JSP pages, not scriptlet expressions. See
this JspFaq entry
.
Point #2: You don't fetch scoped variables with
getParameter
(); you use
getAttribute
() -- the fact that you set them with
setAttribute
() should be a clue.
[
Asking smart questions
] [
About Bear
] [
Books by Bear
]
Vivek Kr Agrawal
Ranch Hand
Posts: 51
I like...
posted 11 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Thanks...
Vivek Agrawal
Consider Paul's
rocket mass heater
.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Passing a list of beans to jsp
Display data from database to jsp page.
Forwarding data to jsp from servlet
Number Format Exception
How to display sum of numbers from a java class to a jsp using custom tag?
More...