Sri,
I cut and paste a part of code from one of my application. This works with both Netscape and IE.
The vars nextHref (
String) and page no (int), qStirngBuffer (StringBuffer) are properly defined in the servlet.
The only difference this code and others code is a missing " "(double quotes) for the href = "....." part.
SAMPLE CODE
-----------
StringBuffer formBodyBuffer=new StringBuffer();
formBodyBuffer.append( "<a href =\"/accnt/servlet/AMSServlet?");
formBodyBuffer.append("destination=");
formBodyBuffer.append(nextHref);
formBodyBuffer.append("&pageNo=");
formBodyBuffer.append((pageNo+1));
formBodyBuffer.append(qStringBuffer.toString());
formBodyBuffer.append( "\" TARGET=\"body\"> Next Page </a>");
out.print(formBodyBuffer.toString());
So yours could be,
------------------
StringBuffer formBodyBuffer=new StringBuffer();
formBodyBuffer.append( "<a href =\"http://cgdu9:8080/servlet/CartServlet1?");
formBodyBuffer.append("bookid=");
formBodyBuffer.append(bookid1);
formBodyBuffer.append( "\" TARGET=\"ANOTHER_FRAME_NAME\"> Add to Cart </a>");
out.print(formBodyBuffer.toString());
[ For better PERFORMANCE
Since servlets are loaded into memory and stay in memory and serves the requests, It is always good idea to use StringBuffers instead of Strings. Whenever we use "first string" + "SecondString" 2 new String Objects are created. But when we use Stringbuffer only 1 StringBuffer object is created in memory and how many appends we make , the new appends are not creating any NEW String objects , instead , they are appended to the old StringBuffer objects. In this way we reduce the no. of new objects created in memory and the servlets can stay in memory for a longer period without any "Out of memory problem"
. This is the reason of the StringBuffer in the sample code
Oc course , we have to use StringBuffer.toString() when we need the String format of the contents in the StringBuffer Object.
]
2. For writing out javascripts, we can just out.print("...."); like any other output. As bill said we have to take care of any special chars which the browser can interpret as different. For this you just write a sample code in a paper and write BOTH System.out.println("...") as well as out.println("...") and in the console window whether they are sent correctly.
regds
maha anna
[This message has been edited by maha anna (edited September 11, 2000).]