java servlets and quotes

R

ryan

I am trying to do the following:

this is part of a servlet. its javascript code.

out.println(" while (str.charAt(str.length - 1) == " ")");

i am getting errors on my embedded quotes? how do i do this? in general how
do i use quotes inside servlets?
 
S

Sudsy

ryan said:
I am trying to do the following:

this is part of a servlet. its javascript code.

out.println(" while (str.charAt(str.length - 1) == " ")");

i am getting errors on my embedded quotes? how do i do this? in general how
do i use quotes inside servlets?

Escape them with the backslash, a well-established standard.
Try this:

out.println( " while (str.charAt(str.length - 1) == \" \") " );

HTH
 
T

Tony Morris

ryan said:
I am trying to do the following:

this is part of a servlet. its javascript code.

out.println(" while (str.charAt(str.length - 1) == " ")");

i am getting errors on my embedded quotes? how do i do this? in general how
do i use quotes inside servlets?

YUK!
At the very least, dispatch the request to a JSP.

Investigate:
WebWork2 (or Struts if you want popularity at the expense of crustiness)
Hibernate (or JDO) if you are using persistence
Velocity (or some other templating engine),
Tapestry
if you have any desire to write a proper application.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top