Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to retrive text from html list?  RSS feed

 
Abhijit Kangale
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hiii all,

I have written following code in which i have to retrive the contents of html list, put it in a string and display it in another page. My code goed like this.

HTML page code:

<html>
<head>
<title> this is my demo page </title>
</head>
<body>
<center><h1> this is my demo page </h1>
<select name="abc" size="15" multiple>
<option value="hhh">bahubali</option>
<option value="rrr">gomatesh</option>
</select><br>
<form action="goto.jsp" method="get" name="jjj">
<input type="submit" name="rrr" value="gotonextpage">
</form>
</center>
</body>
</html>

JSP page code:

<html>
<head>
<title> welcome </title>
</head>
<body>
<center><h1> welcome to next page </h1>
<%

String [] str1=request.getParameterValues("abc");

for(int i = 0; i < str1.length; i++)
{
out.println(str1[i]);
}
%>
</center>
</body>
</html>

I m trying to run this program using Eclipse IDE but it is giving me following error.

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
type Exception report

message

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

exception

org.apache.jasper.JasperException: Exception in JSP: /goto.jsp:11

8:
9: String [] str1=request.getParameterValues("abc");
10:
11: for(int i = 0; i < str1.length; i++)
12: {
13: out.println(str1[i]);
14: }


Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:451)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:373)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

I m really not getting what is the cause of error. Whether getParameterValues() method works with html list or not. If not which method I can use.? Please help me. Suggestions are welcome.

Regards,
Abhijit
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure, but in HTML, the FORM element doesn't enclose the list,


Edit and try.
 
Abhijit Kangale
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello sagar,

thanks... sorry for inconvinence. but it worked fine as per suggested by u. But now the problem is that it is retriving value of option (ie "www" "qqq" as per in the program). but actually i want to retrive the listed items of HTML list. which method i can use for that....? please help.
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Abhijit Kangale wrote: but actually i want to retrive the listed items of HTML list. which method i can use for that....? please help.

"Listed items"?, do you want to retrieve the content text inside the OPTION tag, like "bahubali" and "gomatesh" ?
 
Abhijit Kangale
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ya Sagar the same thing I want to retrive. Which method I can use for that.....? or how can I proceed...?
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, thats simple, just use the same text for the "value" attribute:
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Abhijit Kangale wrote:hello sagar...
ru ther...? please help...

UseRealWords
 
Abhijit Kangale
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks sagar... it worked fine...
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My pleasure
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!