File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes exception while running code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "exception while running code" Watch "exception while running code" New topic
Author

exception while running code

Megha Singhal
Ranch Hand

Joined: Feb 28, 2012
Posts: 225

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.
Swastik Dey
Rancher

Joined: Jan 08, 2009
Posts: 1479
    
    6

How does the jsp and sevlet part of the code look now?


Swastik
Piyush Mangal
Ranch Hand

Joined: Jan 22, 2007
Posts: 196
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

Joined: Feb 28, 2012
Posts: 225

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

Joined: Feb 28, 2012
Posts: 225

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
Rancher

Joined: Jan 08, 2009
Posts: 1479
    
    6



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

Joined: Feb 28, 2012
Posts: 225

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
Rancher

Joined: Jan 08, 2009
Posts: 1479
    
    6

Just for a test, try to forward to some other page may be test.jsp, without using any attributes, and see how it behaves.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19785
    
  20

Megha, I've asked you before in http://www.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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Megha Singhal
Ranch Hand

Joined: Feb 28, 2012
Posts: 225

Rob Spoor wrote:Megha, I've asked you before in http://www.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

Joined: Feb 28, 2012
Posts: 225

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

Joined: Feb 28, 2012
Posts: 225

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

Joined: Oct 27, 2005
Posts: 19785
    
  20

Megha Singhal wrote:
Rob Spoor wrote:Megha, I've asked you before in http://www.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

Joined: Feb 28, 2012
Posts: 225

Rob Spoor wrote:
Megha Singhal wrote:
Rob Spoor wrote:Megha, I've asked you before in http://www.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

Joined: Feb 28, 2012
Posts: 225

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: exception while running code