Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes JSP and the fly likes query string variable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "query string variable" Watch "query string variable" New topic
Author

query string variable

Megha Singhal
Ranch Hand

Joined: Feb 28, 2012
Posts: 225

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

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

Joined: Feb 28, 2012
Posts: 225

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

Joined: Jan 22, 2007
Posts: 196
I don't understand what is not working. What is the result when you use ${NUM}?
Megha Singhal
Ranch Hand

Joined: Feb 28, 2012
Posts: 225

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

Joined: Jan 22, 2007
Posts: 196
Use "../servlet/SerRec?cno=${NUM}" in your href.
Piyush Mangal
Ranch Hand

Joined: Jan 22, 2007
Posts: 196
Please also post the query string which you see in the browser when you click on href link.
Megha Singhal
Ranch Hand

Joined: Feb 28, 2012
Posts: 225

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

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

Joined: Feb 28, 2012
Posts: 225

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

Joined: Jan 22, 2007
Posts: 196


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

Joined: Feb 28, 2012
Posts: 225

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

Joined: Feb 28, 2012
Posts: 225

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
 
subject: query string variable