Win a copy of Building Blockchain Apps this week in the Cloud/Virtualization forum!
  • 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
  • Paul Clapham
  • Liutauras Vilda
  • Knute Snortum
  • Bear Bibeault
Sheriffs:
  • Devaka Cooray
  • Jeanne Boyarsky
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • salvin francis
Bartenders:
  • Tim Holloway
  • Piet Souris
  • Frits Walraven

Key listener using jsp and servlet rather than using JFrame(windows form)

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi currently i am using Jframe to do keylistener to detect what key i type. so example when i type A it will return A and so on for other key. But what i really want is using textarea in jsp and have this similar or same code in servlet. Below are the code in JFrame

 
Bartender
Posts: 3648
16
Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you trying to implement something on the line of those rich text editor (showing the letter count as users type)? Then there are several such tools online.

If not, basically you will be looking HTML onkeyup, onkeydown, onkeypressed functions. Or do such thing in JS. Should look into those JS libraries like GWT, ExtJS etc
 
chan choon chee
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes i am trying to do like when user type the key and it will write in text file.
you know how to use the on key up function as i do not know.
 
K. Tsang
Bartender
Posts: 3648
16
Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

chan choon chee wrote: yes i am trying to do like when user type the key and it will write in text file.
you know how to use the on key up function as i do not know.



Hmm just html. There are lots of event attributes in HTML, onkeyup/onkeypress/onkeydown are just keyboard event attributes. The full list is at http://www.w3schools.com/tags/ref_eventattributes.asp

If your primary goal is to get the content in text area to some text file then you don't need key listeners, just regular old form submission and do/get everything in servlet.

I'm wondering why not use a database instead of storing into text file ... it's a web app
 
chan choon chee
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i need it to be using servlet and jsp so basically i need to have textarea in jsp that is able to type in keystroke and servlet using java code to read and insert in into a text file. can it be done this way?
or is it possible to just be done in pure html code?

 
K. Tsang
Bartender
Posts: 3648
16
Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

chan choon chee wrote:i need it to be using servlet and jsp so basically i need to have textarea in jsp that is able to type in keystroke and servlet using java code to read and insert in into a text file. can it be done this way?
or is it possible to just be done in pure html code?



using servlet to read the text area is ideal. Just getParameter("textarea_parm") to get the content of the text area. In servlet, you can then do whatever you need to do with it, saving in text file, manipulate it, etc.
 
There is no "i" in denial. Tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!