Sumit Israni

Greenhorn
+ Follow
since Jun 20, 2001
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Sumit Israni

Hi,
I am an XML beginner ..looking to create/modify an XSL document dynamically using a Java program..which will be applied to XML to generate HTML
In the example stylesheet which has been created manually ,I need to change the bgcolor and border properties of the 2 table tags. I dont know how to reference the appropriate table(Node).I know that XSL document can be created by any XML API ..but i find that too cumbersome. Is there any short cut(programmatically of course) by which i can modify the properties of the table nodes?I googled, but with little luck.
Can anyone please guide me the right solution.
Thanks a lot

/********************XSL document ****************************/


<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl utput method="html"/>
<xsl:template match="/">
<TITLE>MY REPORT</TITLE>
<xsl:apply-templates/>
</xsl:template>

<xsl:template match="query">
<br></br>
<b>DESCRIPTION OF THE TABLE IS AS FOLLOWS</b>
<br></br>
<table bgcolor="yellow" border="1">

<tr>
<th>COLNAME</th>
<th>DATATYPE</th>
</tr>

<xsl:for-each select="definition/element">
<tr>
<td><xsl:apply-templates/></td>
<td><xsl:value-of select="@type"/></td>
</tr>
</xsl:for-each>
</table>
<br> <b> Table Information</b></br>
<table bgcolor="cyan" border="1">
<tr>
<xsl:for-each select="definition/element">
<td><xsl:apply-templates/></td>
</xsl:for-each>
</tr>
<xsl:for-each select="data/row">
<tr>
<xsl:for-each select="*">
<td><xsl:apply-templates/></td>
</xsl:for-each>
</tr>
</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>
/********************End of XSL document ****************************/
Hey Folks,
Could you please help me sort out this problem urgently.
Well I am falling short of the required time to do it myself!
Hence it is a request.I will be much grateful to anyone who can just help me out .
I am wanting to download an entire directory of images
and want to do so using the com.oreilly.servlet package.
I am also using the ServletUtils class to get it done.
My code is divided into 2 parts
File1 ownloadFile.java
File2:ServletUtilsa.java
<code>
***********DownloadFile.java******************
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import com.oreilly.servlet.*;
public class DownloadFile extends HttpServlet{
HttpServletResponse res;
ServletOutputStream out;
boolean endedLastResponse = true;

public void init(HttpServletResponse response) throws ServletException,IOException {
// Save the response object and output stream
res = response;
out = res.getOutputStream();
// Set things up
res.setContentType("application/x-filler");
out.println();
out.println("--End");
}

public void doPost(HttpServletRequest req,HttpServletResponse resp) throws ServletException,IOException
{
ServletOutputStream out = resp.getOutputStream();
resp.setContentType("application/x-filler");

ServletUtilsa.returnFile(req.getRealPath("/Dir/"), out);
{

MultipartResponse multi = new MultipartResponse(res);
multi.startResponse("text/plain");
out.println("On your mark");
multi.endResponse();
try { Thread.sleep(1000); } catch (InterruptedException e) { }
multi.startResponse("text/plain");
out.println("Get set");
multi.endResponse();
multi.finish();
}
}
}
*********End of DownloadFile.java**************
</code>
<code>
*********ServletUtilsa.java*******************

import java.io.*;
import java.lang.reflect.*;
import java.net.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class ServletUtilsa {
public static void returnFile(String filename,OutputStream out)
throws FileNotFoundException, IOException {
// A FileInputStream is for bytes
FileInputStream fis = null;
File f1=new File(filename);
String s[]=f1.list();

int i;
for (i=0;i<s.length;i++)
{
byte[] buf=new byte[4 * 1024];
buf=s[i].getBytes();
out.write(buf);

}
try {
fis = new FileInputStream(filename);
byte[] buf = new byte[4 * 1024]; // 4K buffer
int bytesRead;
while ((bytesRead = fis.read(buf)) != -1) {
out.write(buf, 0, bytesRead);
}
}
finally {
if (fis != null) fis.close();
}
}
}

**********End of ServletUtilsa.java*************
</code>
Both the files get compiled but I get a NullPointer Exception at output .I want to rectify it and want the popup dialog Box to be displayed for the user to download the directory of Images.
As you can see the directory is specified in this statement.
ServletUtilsa.returnFile(req.getRealPath("/Dir/"), out);
I need a workable solution ..guys..you have the source code as is!Many many thanks.
P.S: Please post the entire code either at my email address: sumiti@hotmail.com
or here whichever is convenient

20 years ago
Hi All,
Could anyone please help me resolve this problem :I want to download an entire directory .I am using the com.oreilly.servlet package .I am utilizing the ServletUtils class in it.Following is the code in it which I want to modify in order to download an entire directory/folder.Of course in the returnFile() method I am passing a Directory name rather than just a file name.
<code>
File f1=new File(dirname);
String s[]=f1.list();
int i;
for (i=0;i<s.length;i++)
{
byte[] buf=new byte[4 * 1024];
buf=s[i].getBytes();
out.write(buf);

}
</code>
I am getting a bit stuck in the above code as to how to output an array of bytes(the array contains the filenames in the directory as obtained by the list() method.) to the output stream.
Any help will be much appreciated.Thanks a lot.


20 years ago
Hi Michael,
Thanks a lot for the prompt response.I will be trying the suggested solution ,however I am wondering if at all a workaround to the problem exists in Javascript .I doubt so because Javascript cannot set the <INPUT TYPE =FILE> to a default value as taken from the hidden variable.If there is any other way of doing it,as you were suggesting of inheriting the hidden variables,can you post a sampler code as to how that would be achieved.As you know there are 2 html forms.The main one with the Overwrite flag set to false and the second form with its OverWrite flag set to true for providing the user to override the file if it already exists in the 1st session.I also dont think this can be achieved using Sessions as they too would require the getParameter method for extracting the value of hidden variables.
I earnestly look forward for your response.Thanks a million.
Regards
20 years ago
Hey Folks,
Your help is urgently required.Does anyone have a solution to the above problem!!I am at pains to find a solution as to how session tracking could be achieved in the above example .The getParameter() method does not work here .So i dont know how to go ahead .
Any help would be greatly appreciated.
Thanks a lot
20 years ago
Hi Michael,
Thanks for your prompt response.I think you got what I tried to convey and that is probably the one of the right solutions.However there are a few problems from my end.
1)I dont know Beans,yes maybe its high time I know them in and out .
2)I am seriously constrained by time limitations ..and another aspect which is there is that the current File Upload is kinda working fine so I would like to hold myself to it as much as I could and
get the changes done on the same if possible.
I would appreciate it if you tell me how my current approach is not appropriate.
I however do feel it could be possible via servlets and passing hidden variables from one form to another ,but how that is to be achieved I dont know .Well thats just my guess!!
P.S:I would like to add here that the File Upload servlet is taken as is from www.java-edge.com with hardly any modifications
by me.
Thanks a lot Michael.
20 years ago
Correction please :
Override flag false in the main form (Form1)and true in the second form(Form2)
20 years ago
Hey Friends,
I am developing a File Upload servlet (yet another one )and I need your help in certain matters .I have taken the servlet code from java-edge.com and am modifying it to give custom behaviour.I have a main page for upload (form upload)(lets call it form 1).If the file to be uploaded already exists on the server then a page is generated by the server saying that file already exists.(form 2)Now it is here(in form 2) that I want to provide an extra button which when submitted would recall the same servlet /or maybe another one and would provide the user for overriding the existing file.
Now as per the code I would set the Override flag to be false in the second form and false in the main form .
Given the case that it is a form based uploading servlet how do I maintain the user session when going to the next form or how do i pass the variables of the first form into second form .
I am also facing another problem that is how do i manage multiple file uploads at a time .This basic system allows only one file per upload .
I hope I have explained my situation ..kindly let me know for clarifications.Thanks a lot
P.S If someone could also throw some light on how to use the com.oreilly servlet (the latest version) it would be lovely but for now I want to focus on developing the current one

20 years ago
Hey Friends
Can anyone please tell me how do I redirect files to an anti virus software before uploading to a server from a servlet .
Thanks in advance
Regards
Sumit
20 years ago
Sorry Shailendra there for spelling your name wrong! I think it must be the Microsoft effect that has taken over me which is why I am making spelling mistakes!!
Muhahahaha , Mapraputa you now have to reply to 4 persons in all
me,Parmeet,Terence and now Shailesh or should we hold Microsoft responsible for this mess??Microsoft certainly makes me go in loops with its product
By the way Mr.Ajit Kalambella's comments are wanting here!
Larry,I personally think that you are absolutely right in your opinion and it is a valid point for further discussion.
Hey fellow ranchers what have you all to say to this ?
20 years ago
Hey Larry,
You put that point across beautifully.But isnt the problem of conflicting namespaces a big one!!!.At least I feel so..Id appreciate if you could give your comment on that.
Thanks for your kind response.
Regards
20 years ago
Hey Larry,
Thanks for your response.Well I did not know this fact as I did not check the details of late.But what I really ponder is why has such kind of design been created at all?I mean this dot hierarchy of packages ..doesnt this create a kind of problem .
That is everytime I require a package I have to check with its latest wrapper.I mean what if I have to have access to a class (or package details)in another root directory then it is not possible?? Or may be I am confused about this thing.I wonder if anyone has to say about this.
20 years ago
Hi there Ravi,
Thanks for your reply .However the problem persists with Internet Explorer 5.0.And the namespace that I used in my program above is actually the one which Microsoft supports as per a book called Mastering XML.As of now the only solution I have available in achieving the desired result is via CSS. But about XSLT no comments!!I am confused