• Post Reply Bookmark Topic Watch Topic
  • New Topic

how jsp can show the value from text file  RSS feed

 
alona ariel
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want that the jsp will show the value of command1 (that it receive from the text)
how I have to write the code servlet and jsp code if I dont know the value(it write on the text not on the programm and the point is that I myshelt dont have to know the value)


my code is:

String name="banana"
if(st.nextToken().equals(name)){

String command1=st.nextToken();
(the value of command1 is yellow)


I want that the jsp will show me
your choice: yellow
 
Muhammad Saifuddin
Ranch Hand
Posts: 1325
Android Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how I have to write the code servlet and jsp code if I dont know the value(it write on the text not on the programm and the point is that I myshelt dont have to know the value)


didn't get you are really want to achieve,

Are you having problem in reading file or display that file text into jsp?
 
alona ariel
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no my priblem is that I cant know how to pass parameter from the text file to jsp.
I try the code:
request.setAttribute(command1,"your choice "+command1);
<% command1=(String)request.getAttribute("your choice "+command1);%>

but the result is null.
 
Muhammad Saifuddin
Ranch Hand
Posts: 1325
Android Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
are you following any book or any tutorial to create this application?

because the way to use to set and get request attribute. is not correct.
 
Paul Yule
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Attributes that you put on the request are a set of Keys/Values. You can then use the key to get value out of the attributes off the request.

request.setAttribute("KEY", myObject);

request.getAttribute("KEY"); //returns myObject

and if you are on a JSP you should retrieve the object using Expression Language/Java Standard Tag Library instead of scriptlets.

<cut value="${KEY}"/> //on your jsp
 
alona ariel
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you for your help now it works well .
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!