Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How i store enter key and space in MySql database

 
Vinod suryawanshi
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends,
I am taking values from user in textfield of jsp, user enter values with spaces and enter keys (in particular format). I want to save that values as it is in table.

I created table advertise, having column adid-INT and adcontent-TEXT,
user enter data in adcontent field from GUI(which is in jsp) following format.

" We have openings... for
-Developer
-Marketing
-Accounts"
latter i store this values in table column adcontent.

But when i retrieve values table and display them, it will look like,
" We have openings... for -Developer -Marketing -Accounts"
In one row.

so its possible to store and retrieve above statement as it is enter by user in mysql database tables.
 
harshvardhan ojha
Ranch Hand
Posts: 157
1
Android Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Vinod, you can save \n in mysql db for every enter pressed, similarly you can keep other signs which which give you back the same indentation in java after retrieval.
 
Vinod suryawanshi
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your replay harshvardhan ojha,
but i am not entering value in database, user enter value in form(which is part of GUI). which i want to save into database as it is. from your answer i got one clue, that if i take value from user and add necessary '\n' and ' ' according to user enter values & Then i enter them into database. May be this will work, i have to check.
But still if you have any other easy solution then please reply....
And one more time, thankss
 
Paul Clapham
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you say you "display" those things, you mean you display them in HTML, right?

And perhaps you didn't remember that HTML normally converts blocks of white-space to a single space character? So for example a series of three space characters would be displayed as just one space, and a new-line character (what you called "enter key") is also displayed as just one space.

In other words your problem has nothing to do with the database and everything to do with how HTML works.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic