• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

calling txt file from jsp

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is some text file with .txt extension with some information like key - value pairs.

sno value

1 apple
2 bat
3 cat


now I will create a jsp page and i will ask user to enter sno .

if anybody enters 1 it has to display apple
if anybody enters 2 it has to display bat and so on.

Can anybody suggest some ways to solve this? thanks in advance


 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds like homework to me - how far have you gotten with this problem?

Can you read and parse the text file?

Bill
 
Sheriff
Posts: 67269
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
William has set you on the correct path. The first step is to create a Java class -- not a JSP -- that reads in the values. This class can then be used from a servlet or Bean to put the data into a usable form for the JSP to consume. A Map perhaps.

If you have trouble with file I/O, there's an I/O forum here where you can get help on that.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!