JSP in for zanka z stream-anjem podatkov iz https..

Problemi z drugimi jeziki kot so c++, cgi, java, itd.
Odgovori
peterv
Prispevkov: 987
Pridružen: 29.03.2002 13:24:32

JSP in for zanka z stream-anjem podatkov iz https..

Odgovor Napisal/-a peterv » 20.01.2010 08:53:29

Pozdrav..
še eno vprašanje imam..

naredim JSP stran in v jsp kodi
naredim tag-e za java kodo in spišem for zanko v kateri iz nekega URL-ja pobiram podatke in jih zapisujem na disk..
recimo:

Koda: Izberi vse

 
<%
       soap = ws_locator.getInDocArchiveWebServiceSoap(new URL(ws_locator.getInDocArchiveWebServiceSoapAddress()));
       System.out.println("smo za soap-om");
       System.out.println("-->" + soap.about());
       ArchiveUserInfo userinfo = new ArchiveUserInfo();
       userinfo.setPassword("in2");

        ArrayOfInt aint = soap.findDoc(userinfo, 2, 1, "*");
        int[] list_id = aint.get_int();
        if (list_id == null) return;
        
        for (int x=0; x < list_id.length; x++)
        {
          ArchiveDocument ad =  soap.getDocInfoAL(userinfo,2,1,list_id[x],"IN2");
          ArrayOfArchiveDocumentLocation xy = ad.getLocations();
         
          ArchiveDocumentLocation[] adl = xy.getArchiveDocumentLocation();
          for (int y=0; y < adl.length; y++)
          {
            
                String dd = adl[y].getFileName();
                dd = dd.substring(dd.lastIndexOf("/"),dd.length());
                System.out.println(dd);
                
                
                urldoc=adl[y].getServer()+adl[y].getFileName();
                System.out.println("URL --> " + urldoc);
                
                url = new URL(urldoc);
                URLConnection connection = url.openConnection();
                 InputStream stream = connection.getInputStream();
                BufferedInputStream in = new BufferedInputStream(stream);
                FileOutputStream file = new FileOutputStream(fdir+dd);
                BufferedOutputStream outx = new BufferedOutputStream(file);
                int i;
                while ((i = in.read()) != -1) {
                    outx.write(i);
                }
                outx.flush();
                stream.close();               
                
             
          }
        }
       
        outStream.close();
  %>
 
V drugi for zanki imam

URLConnection connection = url.openConnection();
InputStream stream = connection.getInputStream();


Iz webservisa dobim URL do dokumenta, katerega bi rad zapisal na lokalni disk...
Prvi dokument se prenese... pri drugem pa odleti z napako:

500 Internal Server Error
java.net.SocketException: Unexpected end of file from server
at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:818)
at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:711)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:635)
at com.sun.net.ssl.internal.www.protocol.https.HttpsURLConnectionOldImpl.getInputStream(DashoA12275)
at _fview._jspService(fview.jsp:86)
[/fview.jsp]
at com.orionserver[Oracle Application Server Containers for J2EE 10g (10.1.2.0.2)].http.OrionHttpJspPage.service(OrionHttpJspPage.java:57)
at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:350)
at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:509)
at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:413)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.2)].server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:65)
at oracle.security.jazn.oc4j.JAZNFilter.doFilter(Unknown Source)
at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.2)].server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:663)
at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.2)].server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:330)
at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.2)].server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:830)
at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.2)].server.http.HttpRequestHandler.run(HttpRequestHandler.java:285)
at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.2)].server.http.HttpRequestHandler.run(HttpRequestHandler.java:126)
at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.2)].util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:186)
at java.lang.Thread.run(Thread.java:534)


Če ta isto kodo izvedem kot java program deluje brez problema..

M.C
Prispevkov: 630
Pridružen: 24.02.2003 14:27:43

JSP in for zanka z stream-anjem podatkov iz https..

Odgovor Napisal/-a M.C » 21.01.2010 19:58:25

Morda imaš malenkost drugačne importe, kako drugo verzijo česa.

Ravno sem nekaj takega prčkal in sem uspel priterat zadevni server do tega da je dosegel max session limit.
In obvestilo o tem ni kar ven skočilo (pač err 500), sem kar malo naokoli iskal kaj se je zgodilo.

probaj kaj takega:

Koda: Izberi vse

boolean try_success = false;
      do
      {
        try
        {
           parser.setConnection((HttpURLConnection) url.openConnection());
           try_success = true;
        }
        catch (Exception ex)
        {
          //1 sec pavze da mu pade število odprtih sej
          try_success = false;
          Thread.currentThread().sleep(1000);

        }
      }while (try_success == false);
Order is heavens first rule. Therefore some must be better than the rest.

peterv
Prispevkov: 987
Pridružen: 29.03.2002 13:24:32

JSP in for zanka z stream-anjem podatkov iz https..

Odgovor Napisal/-a peterv » 25.01.2010 16:40:51

bom probal.. sicer mi ni čisto jasno zakaj mi v normalni kodi stvar deluje v jsp kodi pa šteka..
Itak odpiram nek connection na nekem xy strežniku in ne na localhostu..

Bom probal pa sporočim..

peterv
Prispevkov: 987
Pridružen: 29.03.2002 13:24:32

JSP in for zanka z stream-anjem podatkov iz https..

Odgovor Napisal/-a peterv » 25.01.2010 19:19:36

Hmm.. če grem skozi debug mode skozi mi odleti tle..

InputStream stream = connection.getInputStream();

peterv
Prispevkov: 987
Pridružen: 29.03.2002 13:24:32

JSP in for zanka z stream-anjem podatkov iz https..

Odgovor Napisal/-a peterv » 25.01.2010 19:26:21


peterv
Prispevkov: 987
Pridružen: 29.03.2002 13:24:32

JSP in for zanka z stream-anjem podatkov iz https..

Odgovor Napisal/-a peterv » 25.01.2010 19:45:22

ni ni bug..
nekaj drugega mora bit..

ni mi jasno zakaj mi javi java.net.SocketException: Unexpected end of file from server

Če probam url preko explorerja mi normalno odpre internet stran..

booo.... bom probal še preko servleta..

peterv
Prispevkov: 987
Pridružen: 29.03.2002 13:24:32

JSP in for zanka z stream-anjem podatkov iz https..

Odgovor Napisal/-a peterv » 26.01.2010 20:29:36

aaaaa..
evo sem rešil...

Koda: Izberi vse

 
 URL urlConnection = new URL((String) v.get(x));
                    URLConnection cn = urlConnection.openConnection();
                    cn.connect();
                    InputStream stream = urlConnection.openStream();
            
 

Odgovori