File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

query string variable

 
Megha Singhal
Ranch Hand
Posts: 225
IBM DB2 Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • 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 .
 
Piyush Mangal
Ranch Hand
Posts: 196
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use "../servlet/SerRec?cno=${NUM}" in your href.
 
Piyush Mangal
Ranch Hand
Posts: 196
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Piyush Mangal
Ranch Hand
Posts: 196
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic