• Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
chan choon chee
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

 
K. Tsang
Bartender
Posts: 3633
16
Firefox Browser Java Mac OS X
  • 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: 3633
16
Firefox Browser Java Mac OS X
  • 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: 3633
16
Firefox Browser Java Mac OS X
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!