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
Win a copy of
Helidon Revealed: A Practical Guide to Oracle’s Microservices Framework
this week in the
Java in General
forum!
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
Tim Cooke
paul wheaton
Liutauras Vilda
Ron McLeod
Sheriffs:
Jeanne Boyarsky
Devaka Cooray
Paul Clapham
Saloon Keepers:
Scott Selikoff
Tim Holloway
Piet Souris
Mikalai Zaikin
Frits Walraven
Bartenders:
Stephan van Hulst
Carey Brown
Forum:
Struts
I want Check stdId&Pwd Using Iteration I can't declar iterator variable outside Loop please help me,
RajeshKumar Nayak
Greenhorn
Posts: 6
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
/* * Generated by MyEclipse Struts * Template path: templates/java/JavaClass.vtl */ package com.rajesh; import java.util.ArrayList; import java.util.Iterator; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.struts.action.Action; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.hibernate.Query; import org.hibernate.Session; public class LoginAction extends Action { public LoginAction(){ System.out.println("LoginAction Object is Created"); } public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { LoginForm lf=(LoginForm)form; System.out.println("The Following Details"); String stdId=lf.stdId; String stdPwd=lf.stdPwd; System.out.println("Student Id"+stdId); System.out.println("Student Password"+stdPwd); request.setAttribute("StudentId", stdId); Session sc=MySigleTone.getsSession(); Query hql=sc.createQuery("from com.rajesh.Student"); ArrayList plist=(ArrayList)hql.list(); Iterator it=plist.iterator(); while(it.hasNext()){ Student std=(Student)it.next(); } if(stdId.equalsIgnoreCase(std.getStdid())&& stdPwd.equalsIgnoreCase("nayak")) //give error for std. declaration it error because outside of the loop how i can use this object for test case please give me solution return mapping.findForward("Sus"); else// TODO Auto-generated method stub return mapping.findForward("fail"); } }
Baseet Ahmed
Ranch Hand
Posts: 225
I like...
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
if(stdId.equalsIgnoreCase(std.getStdid())&& stdPwd.equalsIgnoreCase("nayak"));//give error
Please remove the semicolon(;) at the end of if statement.
Also, next time onwards always give error stack trace for better understanding of problem.
---------
Regards
Ahmed
RajeshKumar Nayak
Greenhorn
Posts: 6
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
give error for std. declaration it error because outside of the loop how i can use this object for
test
case please
not ; this is mistake for write can someone solve my problem
Thanks Regards
Rajesh kumar Nayak
tyte kyat
Ranch Hand
Posts: 40
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Have you try this,
Query hql=sc.createQuery("from Student");
without -->
com.rajesh.
--------------------------
or
without changing anything and if you put the following line
System.out.println("size = "+plist.size());
before calling Iterator it=plist.iterator();
what have you got?
There will be plenty of time to discuss your objections when and if you return. The cargo is this tiny ad:
New web page for Paul's Rocket Mass Heaters movies
https://coderanch.com/t/785239/web-page-Paul-Rocket-Mass
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
getDataSource
SaveToken
Debug problem with login form
Help in connecting to oracle10 database using struts
reloading the same page with message - spring mvc
More...