This week's book giveaway is in the Java in General forum.
We're giving away four copies of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 and have ishori Sharan & Adam L Davis on-line!
See this thread for details.
Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

exception while running code

 
Ranch Hand
Posts: 225
IBM DB2 Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Swastik Dey wrote:In you jsp you have something like. What does this mean?
request.getAttribute("userList")!=""

You probably want to make sure that the list not empty?


Problem 2, you are initializing the arraylist inside the loop


So what happens in the above code, every time the loop executes a new arraylist object is created, means it will always store only the last record in the array list. Initialize it before you start the loop.



i make changes suggested by you but still the problem is same.
 
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How does the jsp and sevlet part of the code look now?
 
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I believe you know how to debug the code. You can easily dubug the issue yourself and see if dispatcher.forward(request,response) is being called.
 
Megha Singhal
Ranch Hand
Posts: 225
IBM DB2 Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Piyush Mangal wrote:I believe you know how to debug the code. You can easily dubug the issue yourself and see if dispatcher.forward(request,response) is being called.


yes i tried dubug my prog like following


i disabled

//String str = request.getParameter("P_ID");

as it can't take value from previous page
so output was blank page

and when disabled

String nextJSP = "/editUser.jsp";

RequestDispatcher dispatcher = request.getRequestDispatcher(nextJSP);
dispatcher.forward(request,response);



then it is printing "connect" which i am trying to print for debug
but through this i'm not getting whats the problem
 
Megha Singhal
Ranch Hand
Posts: 225
IBM DB2 Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Swastik Dey wrote:How does the jsp and sevlet part of the code look now?



servlet page is like following


and jsp page is like following
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


You should first initialize userList, then do the condition checking. But you need to know one thing that using scriptlets in jsp is not a recommended approach. Jsp is just your view, try to use jstl/el/custom tags etc.
 
Megha Singhal
Ranch Hand
Posts: 225
IBM DB2 Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Swastik Dey wrote:

You should first initialize userList, then do the condition checking. But you need to know one thing that using scriptlets in jsp is not a recommended approach. Jsp is just your view, try to use jstl/el/custom tags etc.



still it is not redirecting me to the next page.
i try to debug the program then also when i am disabling the request dispatcher then only it is printing something.
i make changes for scriptlets but atleast it should redirect me to the jsp page
my main problem is this only it is not redirecting me to jsp page with variable i am passing through session.
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just for a test, try to forward to some other page may be test.jsp, without using any attributes, and see how it behaves.
 
Sheriff
Posts: 22575
122
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Megha, I've asked you before in https://coderanch.com/t/571565/JDBC/java/error-missing-values to remove all the trailing spaces from your code. I had to again fix two of your posts in this thread to fix the forum layout. Can you please try to remove all those trailing spaces yourself from now on? Thanks.
 
Megha Singhal
Ranch Hand
Posts: 225
IBM DB2 Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rob Spoor wrote:Megha, I've asked you before in https://coderanch.com/t/571565/JDBC/java/error-missing-values to remove all the trailing spaces from your code. I had to again fix two of your posts in this thread to fix the forum layout. Can you please try to remove all those trailing spaces yourself from now on? Thanks.



sorry but i didn't get about which trailing spaces you are talking , i mean where
 
Megha Singhal
Ranch Hand
Posts: 225
IBM DB2 Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Swastik Dey wrote:Just for a test, try to forward to some other page may be test.jsp, without using any attributes, and see how it behaves.



yes this is redirecting to another jsp page
 
Megha Singhal
Ranch Hand
Posts: 225
IBM DB2 Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Swastik Dey wrote:Just for a test, try to forward to some other page may be test.jsp, without using any attributes, and see how it behaves.



yes this is redirecting on other pages so i thnk there is problem jsp file, but what that i'm not able to find out.
 
Rob Spoor
Sheriff
Posts: 22575
122
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Megha Singhal wrote:

Rob Spoor wrote:Megha, I've asked you before in https://coderanch.com/t/571565/JDBC/java/error-missing-values to remove all the trailing spaces from your code. I had to again fix two of your posts in this thread to fix the forum layout. Can you please try to remove all those trailing spaces yourself from now on? Thanks.



sorry but i didn't get about which trailing spaces you are talking , i mean where


Inside your latest two servlet code tags, the last line had several dozen spaces between the final } and the code end tag. I have since removed those extra spaces.
 
Megha Singhal
Ranch Hand
Posts: 225
IBM DB2 Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rob Spoor wrote:

Megha Singhal wrote:

Rob Spoor wrote:Megha, I've asked you before in https://coderanch.com/t/571565/JDBC/java/error-missing-values to remove all the trailing spaces from your code. I had to again fix two of your posts in this thread to fix the forum layout. Can you please try to remove all those trailing spaces yourself from now on? Thanks.



sorry but i didn't get about which trailing spaces you are talking , i mean where


Inside your latest two servlet code tags, the last line had several dozen spaces between the final } and the code end tag. I have since removed those extra spaces.



ok fine.
i'll take care of it in future
 
Megha Singhal
Ranch Hand
Posts: 225
IBM DB2 Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Swastik Dey wrote:Just for a test, try to forward to some other page may be test.jsp, without using any attributes, and see how it behaves.



as you told me i redirect the page to another jsp and it is redirecting.
can you tell me another method to fetch values in the jsp file using Arraylist or where i'm going wrong
reply
    Bookmark Topic Watch Topic
  • New Topic