Use StringBuffer, not String. Then call StringBuffer.append() repeatedly.
I think you might want to consider a different architecture, and a framework such as Struts. John > -----Original Message----- > From: Mufaddal Khumri [mailto:[EMAIL PROTECTED] > Sent: Tuesday, February 25, 2003 4:19 AM > To: Tomcat Users List > Subject: Re: is there a tag or some kind of mechanism that > would do the > following ... > > > I could use a giant String being returned from some static method .. > but the problem is that i would have to do the following: > > static String getString() > { > String str = "<html>" > +"<title>" > +"ding dong bells" > +"</title>" > +"<body></body></html>"; > > return str; > } > > In the above code i will have to type in the quotes and + signs > everywhere since if the string gets too long it will all be > on one line > and the html code from a developer stand point would not be > maintainable. > > Are there any other better ideas to do this ? > > Mufaddal. > On Tuesday, February 25, 2003, at 01:57 PM, Mufaddal Khumri wrote: > > > Hi, > > > > Many times we come across a lot of out.println( ... ) statements in > > our servlets: > > > > public class MyServlet extends .... > > { > > .... > > .... > > > > doPost( ... ) > > { > > ..... > > ..... > > out.println("<html>"); > > out.println("<title>"); > > out.println("ding dong bells"); > > out.println("</title>"); > > out.println("<body>"); > > out.println("</body>"); > > out.println("</html>"); > > ...... > > } > > } > > > > I do know that if your code has more html .. its better to write a > > .jsp file instead of a servlet.java file > > There are some cases where this is unavoidable and I was > wondering if > > there was a way to do something like below in a .java file: > > > > public class MyServlet extends .... > > { > > .... > > .... > > > > doPost( ... ) > > { > > ..... > > ..... > > > > <Some kind of tag that signals to the compiler > that whatever follows > > is to be "out.println(... )" > > > > > <html> > > <title> > > ding dong bells > > </title> > > <body> > > </body> > > </html> > > > > </end of the signalling tag> > > ...... > > } > > } > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
