Hi,
Here <code1> makes a call to <code2>. In code<2>, I first set the mimetype and then a add a header "ekvalue", that I would like to send to the client.
//resp.addHeader("ekvalue", examkey);
Without the addHeader statement, the file contents were being read and sent to the client, earlier. However, after adding "addHeader" statement, just the examkey is being set as part of Response header, and my client can read it. However, the file contents are not being sent. Just one statement is making so much difference !
Is there any problem with the coding?
-Sara
<code1>
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
.........
if (...)
{
..........
String ekey = "ABCDEFG";
PrintWriter pw = response.getWriter();
readData(fName, mtype, pw, response, ekey);
}
.......
}
</code1>
<code2>
private void readData(String filename, String mimetype, PrintWriter out, HttpServletResponse resp, String examkey)
throws ServletException, IOException
{
resp.setContentType(mimetype);
resp.addHeader("ekvalue", examkey);
/// read file contents
........
}
</code2>