aspose file tools*
The moose likes Servlets and the fly likes session tracking using servlets and sessions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "session tracking using servlets and sessions" Watch "session tracking using servlets and sessions" New topic
Author

session tracking using servlets and sessions

shanthi naidu
Ranch Hand

Joined: Nov 13, 2008
Posts: 39
hi all, im trying to run my own application to understand session tracking ... im new to java.. My application is

** i have "two" html files containing total 6 fields. "from1" contains 3 fields, when i click on a button in "form1" it takes you to "form2" with remaining 3 fields *** my application is to insert the values of these 6 fields into the database table named "record".*** for that i used session tracking using sessions as the fields are from two different html pages ... i used one servlet for getting the values from "form1" and put them in a session... and another servlet to get these values from 1st servlet and also the remaining 3 fields from "form2" HERE IS MY CODE:










im using j2dk1.5 version and tomcat 5.5 version IM NOT ABLE TO INSERT THE VALUES INTO THE DATABASE THE ERROR I GOT IS AS SHOWN BELOW



HTTP Status 500 - type Exception report message description The server encountered an internal error () that prevented it from fulfilling this request. exception java.lang.NullPointerException Page2.doGet(Page2.java:47) javax.servlet.http.HttpServlet.service(HttpServlet.java:689) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) note The full stack trace of the root cause is available in the Apache Tomcat/5.5.16 logs. -------------------------------------------------------------------------------- Apache Tomcat/5.5.16



PLEAZE CAN ANYBODY SUGGEST ME ANY SOLUTION

[BPS: took the stack trace out of the code tags to narrow the post a bit]
[ December 09, 2008: Message edited by: Ben Souther ]
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

did you get the DataBase Connection properly ?
Amol Nayak
Ranch Hand

Joined: Oct 26, 2006
Posts: 218
Lets start from the beginning,


You are expecting this to be submitted to Page1 servlet
but see the action you have given form2.html, thats not correct. Should be the /Page1 (assuming you have /Page1 in the url-pattern of Page1 servlet in the web.xml)

Next i assume you have changed the action correctly, still things wont work.
You want to store the String[] in the session as an attribute names String1

Then why are you doing this?



You need to do this



Finally..


What is str1? i am assuming thats is str.

Do these changes and try again , get back if you face any problems.
[ December 09, 2008: Message edited by: Amol Nayak ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61648
    
  67

"shanti",

There aren't many rules that you need to worry about here on the Ranch, but one that we take very seriously regards the use of proper names. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
JavaRanch Sheriff


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
shanthi naidu
Ranch Hand

Joined: Nov 13, 2008
Posts: 39
Thank you all for responding .. i did the changes .. i gone through the code , there were so many mistakes and i rectified them..

thanks a lot.. i got the output..

regards,
Shanthi Naidu.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12823
    
    5
<form method=get action="./Page2">


You really should get in the XHTML habit of properly quoting all attributes:

<form method="get" action="./Page2">


Bill
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: session tracking using servlets and sessions