Stefano Mtangoo 455 Senior Poster

Hi guys,
I have been away Python for long now.
I need to brush with small project that will be downloading images from give url.
I give url and it crawls through all pages in give location and its subfolders and download image. Now two challenges:
1. Crawl through all pages in Given url (Folder and sub folders)
2. Download found Images (urllib2?)
3. Sites need authentication, how do I do?

Please help me point right Direction and I missed you ;)

Stefano Mtangoo 455 Senior Poster

Mh, I'm interested in know how although question was possibilty.
Can you explain it Jwenting?

Stefano Mtangoo 455 Senior Poster

(1) what does he think of GUI toolkits specifically Win32, wxWidgets and QT? Which one does he use? and This is specifically my interest -> What does he think of wxWidgets?

(2) What is his comments on Compilers/Debuggers? Which one is his favorite?

(3) What does he think of IDEs? Which IDE does he use (Vim? Emacs? Geany? Anjuta)

I'll think about others if I'm not late :

Stefano Mtangoo 455 Senior Poster

I have looked at NJ but it is commercial.
What do you recommend from Freeware/OSS camp?

Stefano Mtangoo 455 Senior Poster

yow nothing is illegal these days =)

Ah! a relativist right? If your assumption is true what does word illegal means?
Where did the laws go?

I propose that is your imagination. In real world, illegal things exist and you know what, if you don't believe me POST A LINK TO WAREZ SITE HERE. The mods will DeLeTe it. why? because illegal things (including warez stuffs) exists.

Stefano Mtangoo 455 Senior Poster

Which language did you use?
Sorry for little thread hijack ;)

Stefano Mtangoo 455 Senior Poster

That is :)
I was loading session while I should have used request object.
Ah, you baby in JSP ;)

Stefano Mtangoo 455 Senior Poster

Thanks I will do that

Stefano Mtangoo 455 Senior Poster

Any example on using it with MySQL?
I find hard to understand. I need only functionality to execute DML/DDL of course after connection lastly cleaning

Stefano Mtangoo 455 Senior Poster

Cool thanks!

Stefano Mtangoo 455 Senior Poster

Do you mean this apache one right?

Stefano Mtangoo 455 Senior Poster

Thanks again for such clear explanation.
What pool library do you use or recommend for production enviroment?

Stefano Mtangoo 455 Senior Poster

Hi buddies,
I need to pass data among servlets and I find it very hard.
What I have so far is passing it via session variable but that crashes my app now and then and seem to be bad approach. How do you transfer data among servlets without crashing the application?

Thanks

Stefano Mtangoo 455 Senior Poster

All I need now is the way to enable firewall and automatic update
Thanks

Stefano Mtangoo 455 Senior Poster

That is cool,
I have one question though: How pooled connection differ from the other one?
Thanks for such big example :)

Stefano Mtangoo 455 Senior Poster

thank you for your help.
now it has been solved

If you don't mind, mark it solved :)

Stefano Mtangoo 455 Senior Poster

:)

Stefano Mtangoo 455 Senior Poster

I don't know pyGame, but I think it would be better off using GUI oriented Toolkits, something like wxWidgets or QT or GTK. I'm not sure if pyGame is that much capable.

Stefano Mtangoo 455 Senior Poster

That may explain some programming hiccups in your posts ;)
I'm sort finding NetBeans obsolete. My main programming tool is IntelliJ and sometimes I use Eclipse, but I think I did not use NB since 6.1...

Things have Changed a lot since that day. Try it and see :)

Stefano Mtangoo 455 Senior Poster

No difference as I can see.
Different ways of doing the same thing right?

Stefano Mtangoo 455 Senior Poster

Get back beautiful old Daniweb :'( :'(

Stefano Mtangoo 455 Senior Poster

I have it. The Computer isn't infected but lame as you can see.
I need a way to fix that!

Stefano Mtangoo 455 Senior Poster

Cool I wrote servlet to do Db manip issues and DBClass for database conn issues.
Thanks

Stefano Mtangoo 455 Senior Poster

It is UML class diagram

Stefano Mtangoo 455 Senior Poster

I forgotten to update.
I have removed super.finalize.
is it right?

public void CleanUp(ResultSet rs) throws Throwable {
        if(rs!=null){
            rs.close();
        }
        //do finalization here
        this.conn.close();

    }
Stefano Mtangoo 455 Senior Poster

mean the code below?

if(condtion1 && condtion2){
    echo 'Hello Murali!';
}
Stefano Mtangoo 455 Senior Poster

....And the bad is I cannot Start new thread in some forum including this.
Is Daniweb becoming "prorietary" than "opensource" ;)
Just funny

Stefano Mtangoo 455 Senior Poster

+1 for wordpress!
But is blogspot free? I caannot download it apart from using from their site :)

Stefano Mtangoo 455 Senior Poster

I was infected by Mabezat virus/worm.
I have managed to remove infection and have succeeded. However it have left my firewall and Automatic update disabled. It have also removed searchbox (See attached Image).

Please suggest the way out. I cannot even Install Comodo firewall:(

Stefano Mtangoo 455 Senior Poster

Create Media Player with GUI
These are hinted classes. Expand/reduce them as you wish
GUI Class
Methods: CreateToolBar, CreateMenu, LoadConfig

FileClass
Methods: LoadFile, LoadFolder, LoadPlayList...et al

PlayerClass
Methods: LoadMedia, Play, Pause, Stop, FForward, et al

You can in future even implement that in Java/C++/Python or whatever language

Stefano Mtangoo 455 Senior Poster

Dani,
Why did you changed from old gold to this one?
Colours are too strong IMHO and reading forum is harder.
I agree on new features/Design (I have to use torch to search under bed where is "Post New Thread button") but you need to look if there is another design.

RHS of forum, Ads takes big big space that makes hard to read.
Just my 2cents

Stefano Mtangoo 455 Senior Poster

Can you give process how it starts and how it ends?
Booting from where to Black screen?

Stefano Mtangoo 455 Senior Poster

I cannot understand your question Muralikalpana

Stefano Mtangoo 455 Senior Poster

would you repost the code, this time wrapping into code-tags?

Stefano Mtangoo 455 Senior Poster

And then called it in finally

DBClass db = new DBClass();
        
String sql = "SELECT * FROM user ";       
try{
           ResultSet rs = db.dbSelect(sql);
           return rs;
       }
catch(Exception e){
           e.printStackTrace();
           return null;
       }
finally{
           db.CleanUp(rs);
       }
Stefano Mtangoo 455 Senior Poster

I have made this function which I call Manually after playing with my Queries. Is it good on your opinion?

public void CleanUp(ResultSet rs) throws Throwable {
        if(rs!=null){
            rs.close();
        }
        //do finalization here
        super.finalize(); //not necessary if extending Object.
        this.conn.close();

    }
Stefano Mtangoo 455 Senior Poster

So, what approach would be best if I want to implement my Own?
In C++ I would do all cleaning at destructor.

Stefano Mtangoo 455 Senior Poster

I have tried and see that If I pass 400 rows it works fine but if I pass 500 rows it fails! Is that limitation to sessions?

Stefano Mtangoo 455 Senior Poster

Here is my error
In servlet I declare
session.setAttribute("pageContents", pageContents); while in JSP I use request.getSession().getAttribute("contentPage");

Now, is it good to pass thousands of table values into session object? Why?

Stefano Mtangoo 455 Senior Poster

Hi All,
I have JSP and Servlet that need to "talk" to each other. Actually I need to get record from database, fill it in JSP file. I have created Servlet that does the query and gets the result. I need those results to be shown on JSP file. In PHP I will just include the PHP file that does the query but I cannot find that simple way in JSP.

Trying to fix I came up with this method. When link is first clicked, it goes to servlet. Servlet processes it and posts results back to JSP. I'm using session to communicate. But Session is always null at JSP. Please see code and help me point out the error.

Also is this good method for table with thousands of data?
Thanks

Servlet code

package lam;

import javax.servlet.http.HttpServlet;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import java.sql.*;

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.RequestDispatcher;
import javax.servlet.http.HttpSession;

public class LAMHistory extends HttpServlet {

    public void GetHistory(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        PrintWriter out = resp.getWriter();
        try {
            //Write a page with only rows. The code should be put between <table> </table> tags
            ResultSet res = this.getAllTableRows();
            int i; //iterator counter
            //test variable - DELETE IT
            int count = 0;
            String pageContents = "";
            ResultSetMetaData md = res.getMetaData();
            int colCount =  md.getColumnCount();
            while (res.next()) {
                if (count > 50) {
                    break;
                }
                //extract one row at a time and put it in table row
                pageContents = pageContents …
Stefano Mtangoo 455 Senior Poster

Try this

RequestDispatcher dispatcher = req.getRequestDispatcher("./Somehwhere/history.jsp");
            if(dispatcher!=null){
                //redirect to history page
                dispatcher.forward(req, resp);
            }
            else{
                //redirect to error page
                out.print("Sorry, redirection failed");
            }
Stefano Mtangoo 455 Senior Poster

See this and Criticize because It still throws errors

java.sql.SQLException: Before start of result set
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1075)
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:989)
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:984)
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:929)
        at com.mysql.jdbc.ResultSetImpl.checkRowPos(ResultSetImpl.java:842)
        at com.mysql.jdbc.ResultSetImpl.getStringInternal(ResultSetImpl.java:5657)
        at com.mysql.jdbc.ResultSetImpl.getString(ResultSetImpl.java:5577)
        at dbclass.MainApp.main(MainApp.java:16)
BUILD SUCCESSFUL (total time: 1 second)
package dbclass;
//imports
import java.sql.*;

class DBClass {
    
    //Ctor
    DBClass()  {
        try {
            Class.forName(this.dbClass).newInstance();
            conn = DriverManager.getConnection(this.dbHost + this.dbName, this.dbUser, this.dbPassword);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    //private
    private String dbHost = "jdbc:mysql://localhost:3306/";
    private String dbUser = "root";
    private String dbPassword = "ilovejesus";
    private String dbClass = "com.mysql.jdbc.Driver";
    private String dbName = "sitedb";
    public Connection conn = null; //holds connection
    public ResultSet rs = null; //holds result

    //informartive query
    public ResultSet dbSelect(String sql){
        try {
            Statement stmt = this.conn.createStatement();
            rs = stmt.executeQuery(sql);
        } catch (Exception e) {
            //should email admin the error message
            e.printStackTrace();
            rs = null;
        } finally {
            return rs;
        }
    }

    //All update methods
    public int dbChange(String sql){
        int i = 24;
        try {
            Class.forName(this.dbClass).newInstance();
            conn = DriverManager.getConnection(this.dbHost + this.dbName, this.dbUser, this.dbPassword);
            PreparedStatement preparedSQL = this.conn.prepareStatement(sql);
            i = preparedSQL.executeUpdate();

        } catch (Exception e) {
            //should email admin the error message
            e.printStackTrace();
            i = -24; //error somewhere
        } finally {
            return i; //error somewhere
        }
    }


  //Dtor
  @Override
  protected void finalize()throws Throwable{
  //do finalization here
  super.finalize(); //not necessary if extending Object.
  this.conn.close();

}



}//end class
Stefano Mtangoo 455 Senior Poster

I got it. At top of the post

Stefano Mtangoo 455 Senior Poster

And due to new design, I cannot see "Solved" button

Stefano Mtangoo 455 Senior Poster

Cool, Just change loop to while loop and it works. You need to call next before retrieve from resultset

Stefano Mtangoo 455 Senior Poster

See this and Criticize because It still throws errors

java.sql.SQLException: Before start of result set
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1075)
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:989)
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:984)
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:929)
        at com.mysql.jdbc.ResultSetImpl.checkRowPos(ResultSetImpl.java:842)
        at com.mysql.jdbc.ResultSetImpl.getStringInternal(ResultSetImpl.java:5657)
        at com.mysql.jdbc.ResultSetImpl.getString(ResultSetImpl.java:5577)
        at dbclass.MainApp.main(MainApp.java:16)
BUILD SUCCESSFUL (total time: 1 second)
package dbclass;
//imports
import java.sql.*;

class DBClass {
    
    //Ctor
    DBClass()  {
        try {
            Class.forName(this.dbClass).newInstance();
            conn = DriverManager.getConnection(this.dbHost + this.dbName, this.dbUser, this.dbPassword);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    //private
    private String dbHost = "jdbc:mysql://localhost:3306/";
    private String dbUser = "root";
    private String dbPassword = "ilovejesus";
    private String dbClass = "com.mysql.jdbc.Driver";
    private String dbName = "sitedb";
    public Connection conn = null; //holds connection
    public ResultSet rs = null; //holds result

    //informartive query
    public ResultSet dbSelect(String sql){
        try {
            Statement stmt = this.conn.createStatement();
            rs = stmt.executeQuery(sql);
        } catch (Exception e) {
            //should email admin the error message
            e.printStackTrace();
            rs = null;
        } finally {
            return rs;
        }
    }

    //All update methods
    public int dbChange(String sql){
        int i = 24;
        try {
            Class.forName(this.dbClass).newInstance();
            conn = DriverManager.getConnection(this.dbHost + this.dbName, this.dbUser, this.dbPassword);
            PreparedStatement preparedSQL = this.conn.prepareStatement(sql);
            i = preparedSQL.executeUpdate();

        } catch (Exception e) {
            //should email admin the error message
            e.printStackTrace();
            i = -24; //error somewhere
        } finally {
            return i; //error somewhere
        }
    }


  //Dtor
  @Override
  protected void finalize()throws Throwable{
  //do finalization here
  super.finalize(); //not necessary if extending Object.
  this.conn.close();

}



}//end class
Stefano Mtangoo 455 Senior Poster

Thanks A lot
It makes sense of error now

Stefano Mtangoo 455 Senior Poster

I have done this and doesn't work either
it throws errors:

HTTP Status 500 -

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

java.lang.RuntimeException: Uncompilable source code - doGet(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) in dummy.FillGazillionData cannot override doGet(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) in javax.servlet.http.HttpServlet; overridden method does not throw java.sql.SQLException
dummy.FillGazillionData.doGet(FillGazillionData.java:74)
javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)

note The full stack trace of the root cause is available in the Apache Tomcat/6.0.20 logs.
Apache Tomcat/6.0.20

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dummy;

import java.sql.*;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author smtangoo
 */
public class FillGazillionData extends HttpServlet {

    /** 
     * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException, SQLException{
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        Connection connection = null;
        try {

            String sqlApp = "INSERT INTO application VALUES (NULL, 810, 2010-08-26, 2010-10-27, 30, \"Dummy Leave\",  \"Dummy Reason \",  \"Applied \")";
            String sqlUser = "INSERT INTO user VALUES(810,  \"Tomcat Jerry \",  \"Virus Eater \",  \"Cats \",  \"Tomcat \",  \"Hunter \", 0754710410,  \" tomcat@vodacom.co.tz\",  \"YES \", 89,  \"Manager \",   \"Approving \",  \"Bigger Tomcat \",  \"HOD \" )";
            String sqlApproval = "INSERT INTO approval VALUES(NULL, tomcat@yahoo.com,
Stefano Mtangoo 455 Senior Poster

Any simple illustration/Example?

Stefano Mtangoo 455 Senior Poster

So where should I close my connection?
Or should I leave that and it will clean for me?
Won't it cause leaks?
Please someone who knows lend me a help