Win a copy of Rust Web Development this week in the Other Languages 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

query string variable

 
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
for the following code


NUM is the value which i set in servlet through following code

so my problem NUM value is showing in the getAttribute against CNo but not in the query string of the page .
 
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why are using scriplet on JSP page. You should be using EL and JSTL tag on JSP page.

Please use ${NUM} instead of NUM in your href element.
 
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:Why are using scriplet on JSP page. You should be using EL and JSTL tag on JSP page.

Please use ${NUM} instead of NUM in your href element.



i used that also but it is still not working
 
Piyush Mangal
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 don't understand what is not working. What is the result when you use ${NUM}?
 
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 don't understand what is not working. What is the result when you use ${NUM}?


it should redirect me to the servlet page but it is giving following error


HTTP Status 500 -

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

java.lang.NumberFormatException: null
java.lang.Integer.parseInt(Unknown Source)
java.lang.Integer.parseInt(Unknown Source)
SerRec.doPost(SerRec.java:28)
SerRec.doGet(SerRec.java:20)
javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServlet.java:402)
org.apache.catalina.servlets.InvokerServlet.doGet(InvokerServlet.java:134)
javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
InfonetFilter.doFilter(InfonetFilter.java:43)

note The full stack trace of the root cause is available in the Apache Tomcat/6.0.18 logs.
Apache Tomcat/6.0.18

 
Piyush Mangal
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Use "../servlet/SerRec?cno=${NUM}" in your href.
 
Piyush Mangal
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please also post the query string which you see in the browser when you click on href link.
 
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:Use "../servlet/SerRec?cno=${NUM}" in your href.


i change it and it is redirecting me to following url


http://localhost:8080/servlet/SerRec?ccno=${NUM}

 
Piyush Mangal
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Seems like EL is not enabled on your jsp. Search the forum and you will find lot of posts regarding the same.
Although It is not a good pratice to use scriplet but you can try with "../servlet/SerRec?cno=<%= request.getAttribute("NAME") %>" in your href.
 
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:Seems like EL is not enabled on your jsp. Search the forum and you will find lot of posts regarding the same.
Although It is not a good pratice to use scriplet but you can try with "../servlet/SerRec?cno=<%= request.getAttribute("NAME") %>" in your href.


on my servlet page i am getting above variable like below

and my query to fetch values are following


select M_CNO,M_NAME,M_RELATION, from M_BENEFIT where M_EMPL_NO="+M_EMPL_NO;



but it is not redirecting to my jsp page having redirection through servlet and giving following exception


HTTP Status 500 -

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

java.lang.NumberFormatException: For input string: "abc"
java.lang.NumberFormatException.forInputString(Unknown Source)
java.lang.Integer.parseInt(Unknown Source)
java.lang.Integer.parseInt(Unknown Source)
SerRec.doPost(SerRec.java:28)
SerRec.doGet(SerRec.java:20)
javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServlet.java:402)
org.apache.catalina.servlets.InvokerServlet.doGet(InvokerServlet.java:134)
javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
InfonetFilter.doFilter(InfonetFilter.java:43)

note The full stack trace of the root cause is available in the Apache Tomcat/6.0.18 logs.
Apache Tomcat/6.0.18



"abc" is having data in my record so query string is working but why it is not redirecting me to the page i want.
 
Piyush Mangal
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator



java.lang.NumberFormatException: For input string: "abc"
java.lang.NumberFormatException.forInputString(Unknown Source)
java.lang.Integer.parseInt(Unknown Source)
java.lang.Integer.parseInt(Unknown Source)


String cn = request.getParameter("cno") is returning abc which is not an Integer value so when you are trying to parse "abc" to an Integer, you are receiving NumberFormatException.
Please update your db record with proper integer value if it is supposed to be an Integer.

 
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:



java.lang.NumberFormatException: For input string: "abc"
java.lang.NumberFormatException.forInputString(Unknown Source)
java.lang.Integer.parseInt(Unknown Source)
java.lang.Integer.parseInt(Unknown Source)


String cn = request.getParameter("cno") is returning abc which is not an Integer value so when you are trying to parse "abc" to an Integer, you are receiving NumberFormatException.
Please update your db record with proper integer value if it is supposed to be an Integer.



now this is giving following error


An Error Had occurred while accessing the database
--------------------------------------------------------------------------------
ORA-00904: "M_EMPL_NO": invalid identifier

 
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

Megha Singhal wrote:

Piyush Mangal wrote:



java.lang.NumberFormatException: For input string: "abc"
java.lang.NumberFormatException.forInputString(Unknown Source)
java.lang.Integer.parseInt(Unknown Source)
java.lang.Integer.parseInt(Unknown Source)


String cn = request.getParameter("cno") is returning abc which is not an Integer value so when you are trying to parse "abc" to an Integer, you are receiving NumberFormatException.
Please update your db record with proper integer value if it is supposed to be an Integer.



now this is giving following error


An Error Had occurred while accessing the database
--------------------------------------------------------------------------------
ORA-00904: "M_EMPL_NO": invalid identifier



my this problem has solved.
thanks
 
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic