This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

session tracking using servlets and sessions

 
shanthi naidu
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
did you get the DataBase Connection properly ?
 
Amol Nayak
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65225
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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
 
shanthi naidu
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13074
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<form method=get action="./Page2">


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

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


Bill
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic