I am generating JavaScript pages through Java code like:
FileOutputStream fs=new FileOutputStream("C:\\Documents and Settings\\prajakta\\Desktop\\searcheng.html");
OutputStreamWriter out=new OutputStreamWriter(fs);
out.write("<script language='JavaScript' type='text/javascript'>");
out.write("var str=new String('C:\\Documents and Settings\\prajakta\\Desktop\\substr.html');");
out.write("var beg=str.lastIndexOf('\\');");//double' \' **Problem Stmt**
And so on.
The problem is when searcheng.html is created it contains
var beg=str.lastIndexOf('\');//single '/'
which creates a problem in finding index of ‘\’.
How should I write this problem so that it will contain double “\”?
Similarly how should I write a statement
out.write("document.write('< a href='str'> '+str.slice(beg+1,end)+' </a>');");
so that it will create statement in JavaScript as
document.write('< a href=" 'str' "> '+str.slice(beg+1,end)+' </a>');
and the link will go to page whose address is stored in str?
should do the trick. Double for Java, double again for JavaScript…