sevlets and javascript

my servlet response should generate a html page having <a href=someotherservlet>clickhere</a> as part of response. when that href is clicked 'someotherservlet' is called.so far it is fine. now i want this 'someotherservlet'to display the result/response not in the current frame but another frame, say frame2. how do i do it ? ii) while generating the response in servlet as a html page can i have some script embedded in out.prinln(" ")statements of the servlet. thank you, sri

<a href="someotherservlet" target="NotherFrame" >clickhere</a> >> while generating the response in servlet as a html page can i have some script embedded in out.prinln(" ")statements of the servlet. Sure, why not? You will have to be careful of escaping quotes correctly, but there is nothing magic about script statements. Bill

Originally posted by William Brogden: <a href="someotherservlet" target="NotherFrame" >clickhere</a> >> while generating the response in servlet as a html page can i have some script embedded in out.prinln(" ")statements of the servlet. Sure, why not? You will have to be careful of escaping quotes correctly, but there is nothing magic about script statements. Bill

hi, this is servlet response: out.print("<a href=http://cgdu9:8080/servlet/CartServlet1?bookid=" +bookid1 + " >add tocart<a>"); bookid1 is a parameter in urlrewriting.servlet is doing fine.but i want its reult in the 'rightframe' i tried TARGET in form ,href tags.the most i am getting is a new window. other frame title is -'rightframe' now,please rewrite that statement so it would work. thank you sri

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.

[ 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).]