Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Struts
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:
Struts
passing values from jsp to action class
Santhosh Puttu
Greenhorn
Posts: 27
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi , I am creating a page where i am displaying some data.
Now i want to display only five items in first page , next five in other page.
Then i am querying database to display accordingly.
My code is :
//user.jsp //I am trying to pass values from my user.jsp to useraction.java . <tr ><a href="<%=request.getContextPath()%>/User.do?method=searchStudent&page=1%">1</a> <a href="<%=request.getContextPath()%>/User.do?method=searchStudent&page=2%">2</a>
useraction.java public ActionForward searchStudent(ActionMapping map, ActionForm form, HttpServletRequest req, HttpServletResponse res) throws Exception { String page1=StringUtility.strVal(req.getParameter("page")); System.out.println("Page1 NO for student,"+page1); // Output is showing null in this line Integer page= new Integer("page1"); System.out.println("Page NO for student,"+page); if(page==1) { students = userInfoDAO.findFirst(); } else { students = userInfoDAO.findSecond(); } staff = facultyDAO.findFirst(); System.out.println("Students List size " + students.size()); req.setAttribute("students", students); req.setAttribute("staff", staff); req.setAttribute("item", 0); return map.findForward("searchUser"); }
How to pass the values Can you show me the way?
//I tried combinations like: <a href="<%=request.getContextPath()%>/User.do?method=searchStudent&page"<%=1%>>1</a> <a href="<%=request.getContextPath()%>/User.do?method=searchStudent&page"<%=2%>>2</a>
and
<a href="<%=request.getContextPath()%>/User.do?method=searchStudent&page"+1></a>
I don't know how to this.
Help me.
Suraj Savaratkar
Ranch Hand
Posts: 104
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
If are you using
struts
1.2 then you must declare a entry into web.xml regarding to request.getContextPath().
before that you have to set into web.xml. Then
you should
able to get values from request.getContextPath().
Thanks.
David Newton
Author
Posts: 12617
I like...
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
@suraj: What?
@Santhosh: Did you try printing out the value of the parameter before running your StringUtility method on it?
And line 11 will not do what you think it will.
Santhosh Puttu
Greenhorn
Posts: 27
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
@David: No, David. Good point I will try that.
Will get back if I still have problems.
Your mind is under my control .... your will is now mine .... read this tiny ad
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
The diff btw the two include method
req.setAttribute problem
Initialising request scoped bean
JSP Bean error
retrieving parameter stored in req.getParameter()
More...