Radha MahaLakshmi

Ranch Hand
+ Follow
since Mar 28, 2003
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Radha MahaLakshmi

Hi

I am using URLConnection class to read some data from a specific website where the data gewts updated everyday.We are accessing this through our proxy server.Some times when we access the site through out program we are gettgin old data where as if we access the same url form a browser we are getting latest data.

is there anyway we can get rid of this cacheing problem.

i am tryimg to open this url for 50 times just to ensure its gettgin refreshed.but no use.

Could you please suggest me some solution.

here is my code

---------------------------------------
private boolean fileDownload(String fromurl,String local,String filename) throws Exception {

System.out.println(">>>>>>>>>>>filename:"+filename);
try {
if (proxyHost !=null && !proxyHost.trim().equals("") && proxyPort !=null && !proxyPort.trim().equals("")) {
Properties props = System.getProperties();
props.put("http.proxyHost", proxyHost);
props.put("http.proxyPort", proxyPort);
}

String sCurrBussDay = getCurrBussinessDay();

sCurrBussDay = sCurrBussDay.substring(0,4)+sCurrBussDay.substring(5,7)+sCurrBussDay.substring(8,10);

while(iConnectionCount<=30)
{
URL url = new URL(fromurl);
URLConnection urlConn = url.openConnection();

urlConn.setDefaultAllowUserInteraction(false);
urlConn.setDefaultUseCaches(false);
urlConn.setUseCaches(false);
urlConn.setDoInput(true);


InputStream stream = urlConn.getInputStream();
BufferedReader reader = new BufferedReader (new InputStreamReader(stream));
String line = reader.readLine();
dataDate = line.substring(0,8);

cat.info("sCurrBussDay:"+sCurrBussDay);
cat.info("dataDate:"+dataDate);
if(sCurrBussDay.equals(dataDate))
{
BufferedWriter writer = new BufferedWriter(new FileWriter(new File(local+"/"+filename)));
while (line != null)
{
writer.write(line);
writer.newLine();
line = reader.readLine();
}
writer.flush();
writer.close();
reader.close();
cat.info("fileDownload: for dataDate="+dataDate+" Today: "+processDate.substring(0,10));
iConnectionCount++;
break;
}
else
{

iConnectionCount++;
continue;
}


}


cat.info("fileDownload from: "+fromurl+" save to: "+local+"/"+filename);
cat.info("Total Attempts to get latestData :"+iConnectionCount);
cat.info("dataDate:"+dataDate);
cat.info("sCurrBussDay:"+sCurrBussDay);

if(!sCurrBussDay.equals(dataDate))
return false;
else
return true;


} catch (MalformedURLException ue) {
throw new Exception ("fileDownload: MalformedURLException: "+ue.getMessage());
} catch (IOException ioe) {
throw new Exception ("fileDownload: IOException: "+ioe.getMessage());
}
}
---------------------------------------------

Thanks and regards
Radha
[ December 21, 2004: Message edited by: Radha MahaLakshmi ]
20 years ago
Hi
Thanx for the reply.
My application needs to be deployed on UNIX.

Is there anyway i can sort on a column of spread sheet through java using POI.

Regards
Radha
20 years ago
Hi All

I need to extract data from an excel for furtha processing.
I am using POI to extract the data and i could able to do it successfully.
I want to know is there any way we can sort the sheet by a column through POI.

Thanks and Regards
Radha
20 years ago
Hi all
When i am able to run servlets,jsps and ejbs with weblogic and some other app servers why do i need to run servlets and jsp in tomcat and use jboss for ejbs.
Is there any advantage in using this combination over weblogic or any other app server which facilitets in running all three.
regards
Radha
21 years ago
Hi All

I would like to know whether i can deploy ejbs in tomcat4.1.27???
I am able to run jsps and servlets but dont know how to run ejbs??I wanted to know how to deploy a small ejb application.Cab some body help me.
Regards
Radha
[ September 28, 2003: Message edited by: Radha MahaLakshmi ]
21 years ago
Hi all
I need to soecidy the db name before SP name as matrix_xref..get_user_func insted get_user_func then its working.
Thanks
Radha
Hi
I am using sybase database and trying to call a SP.
The following code i am using.
import java.sql.*;
public class javaTest
{
public static void main(String [] str1)
{
try
{
String svr = "tkd-imsyb-01.tk.jp.chase.com:4100";
String uid ="JBOND";
String pwd ="waltherppk";
String department = "MTB";
Class.forName("com.sybase.jdbc2.jdbc.SybDriver");
Connection con = DriverManager.getConnection("jdbc:sybase:Tds:"+svr,uid, pwd);
Statement stm = con.createStatement();
ResultSet rst = stm.executeQuery("exec get_user_func 'YKIDACHI','cftrade' ");
while(rst.next())
{
System.out.println("-----:"+rst.getString(0));
}

}catch(Exception e)
{
e.printStackTrace();
}
}
}

When i run this program its giving the following exception.
java.sql.SQLException: JZ0R2: No result set for this query.
at com.sybase.jdbc2.jdbc.ErrorMessage.raiseError(ErrorMessage.java:482)
at com.sybase.jdbc2.jdbc.SybStatement.queryLoop(SybStatement.java:1525)
at com.sybase.jdbc2.jdbc.SybStatement.executeQuery(SybStatement.java:149
5)
at com.sybase.jdbc2.jdbc.SybStatement.executeQuery(SybStatement.java:402
)
at javaTest.main(javaTest.java:22)

If i execute the SP from isql it gives me a result.
Can some body help me.
Radha
I tried as in http://jakarta.apache.org/struts/installation.html and it worked
i also tried as specified above but could not succeed.Its giving some exceprion like
org.apache.jasper.JasperException
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:254)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2416)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:601)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:392)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)
at java.lang.Thread.run(Thread.java:479)

root cause
javax.servlet.ServletException
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:536)
at org.apache.jsp.LoginView_jsp._jspService(LoginView_jsp.java:91)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:210)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2416)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:601)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:392)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)
at java.lang.Thread.run(Thread.java:479)
--------------------------------------------------------------------------------

Regards
Radha
21 years ago
Hi
I am new to design and started working on a design for small a we base application.Application is pretty simple.It will read data from database and display as various pdf reports in different formats.So i am thinking of having a baseservlet which is an abstract class containing some concrete methods used in generating PDF,metods for DB activity like getting connection from a Connectionpool(another class responsible for maintaining connection pool)some abstract methods like executeHTTPrequest which will be implemented in each servlet associated with a one report.In this function i will form the SQL and construct the pdf and display.
Suggest me whether my approach is ok or i need to think in a different perspective.
Regards
Radha
Hi
Is there any book or site which explains the patterns in terms of real life implementations??? or explains the patterns with simple examples???
i am reading the GOF book but the i am not able to understand the examples clearly.
for bridge pattern can you give me a simple example as you have given for adapter.
Regards
Radha
Hi
As specified in my earlier post i had used the instructions given in the following article
http://www.javaranch.com/newsletter/Mar2002/newslettermar2002.jsp#struts
and i could able to compile the example.
When i run http://127.0.0.1:8080/struts/jsp/LoginView.jsp
its giving some exception like
org.apache.jasper.JasperException: File "/WEB-INF/struts.tld" not found
i searched for "struts.tld" and it was not there in my machine.I downloaded the jakarta-struts-1.1 from apache site only.
struts.tld is part of this zip or do we need to download it seperately.
Please provide me some pointers.
Radha
21 years ago
Hi All
I am reading about adapter pattern from design patterns book and it says
intent of adapter pattern is
"Convert the interface of a class into another interface clients expect".
Is this means, we implemented our application according to some third party intrfaces and if there is a need to chage those interfaces we can use a adapter to convert the new interfaces as old,which client expects??
Please correct me if my understanding is wrong??
Can you please explain me in what conditions we can really use adapter pattern???
Hi Gayatri
I am tring to download and setup akarta-struts-1.1.zip but not able to do it.
i installed tomcat4.1.27 and i found struts.jar and some tld files.
i tried to setup as given in the following article.
http://www.javaranch.com/newsletter/Mar2002/newslettermar2002.jsp#struts
but could not able to succedd.
Could you please help me for the same.
Regards
Radha
21 years ago
Hello Murthy Narasimha
Thank you for the link.I have been struggling with this since 2 days.
The given example worked perfectly.Now i have to do my application accordingly.
Anyway thanks for the help.
Regards
Radha
21 years ago
JSP
Hi
I am trying to generate PDF from servelet.I tried with JSP but could not able to succedd.Now i am trying with servlet its not giving any exceptions but pdf report is not getting disdplayed and my browser window is getting hanged.
Can some body help me pleae..
Here is my code
import java.io.PrintWriter;
import java.io.IOException;
import java.io.File;
import java.util.Date;
import javax.servlet.http.*;
import javax.servlet.*;
import com.lowagie.text.*;
import com.lowagie.text.pdf.PdfWriter;
import com.lowagie.text.html.HtmlWriter;
public class Chap0105 extends HttpServlet {
public void doGet (HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
// we retrieve the presentationtype
String presentationtype = "pdf";
// step 1
System.out.println("---inside servelit----");
Document document = new Document(PageSize.A4.rotate(), 10, 10, 10, 10);
try {
// step 2: we set the ContentType and create an instance of the corresponding Writer
if ("pdf".equals(presentationtype)) {
response.setContentType("application/pdf");
PdfWriter.getInstance(document, response.getOutputStream());
}
else if ("html".equals(presentationtype)) {
response.setContentType("text/html");
HtmlWriter.getInstance(document, response.getOutputStream());
}
else {
response.sendRedirect("http://www.lowagie.com/iText/tutorial/ch01.html#step2");
}
// step 3
document.open();
// step 4
document.add(new Paragraph(new Date().toString()));
}
catch(DocumentException de) {
de.printStackTrace();
System.err.println("document: " + de.getMessage());
}
// step 5: we close the document (the outputstream is also closed internally)
document.close();
}
}
Regards
Radha
21 years ago