Bonjour,
J'ai une class java qui fonctionne très bien dans projet normal
Moi je jeux que cette class sera exécuter dans un projet web
avec jsp
comment je peux importer cette class
comment je peux voir la résultat de l'exécution de ma classe dans une page web
NB-> j'utilise NetBeans6.5+JDK6
Il faut d'abord ajouter la bibliothèque snmp4j au projet et clle ci se trouve ici http://www.snmp4j.org/html/download.html
voila ma class test.java
******************************************************************
import java.io.IOException;
import org.snmp4j.CommunityTarget;
import org.snmp4j.PDU;
import org.snmp4j.Snmp;
import org.snmp4j.TransportMapping;
import org.snmp4j.event.ResponseEvent;
import org.snmp4j.event.ResponseListener;
import org.snmp4j.mp.SnmpConstants;
import org.snmp4j.smi.Address;
import org.snmp4j.smi.GenericAddress;
import org.snmp4j.smi.OID;
import org.snmp4j.smi.OctetString;
import org.snmp4j.smi.VariableBinding;
import org.snmp4j.transport.DefaultUdpTransportMapping;
public class test {
// @param args
// @throws IOException
public static void main(String[] args) throws IOException
{
Address targetAddress = GenericAddress.parse("udp:127.0.0.1/161");
TransportMapping transport = new DefaultUdpTransportMapping();
Snmp snmp = new Snmp(transport);
transport.listen();
CommunityTarget target = new CommunityTarget();
target.setCommunity(new OctetString("public"));
target.setAddress(targetAddress);
target.setRetries(2);
target.setTimeout(1500);
target.setVersion(SnmpConstants.version1);
PDU pdu = new PDU();
pdu.add(new VariableBinding(new OID(new int[] {1,3,6,1,2,1,1,7})));
pdu.add(new VariableBinding(new OID(new int[] {1,3,6,1,2,1,1,5})));
pdu.setType(PDU.GETNEXT);
ResponseListener listener = new ResponseListener()
{
public void onResponse(ResponseEvent event)
{
((Snmp)event.getSource()).cancel(event.getRequest(), this);
System.out.println("Received response PDU is: "+event.getResponse());
}
};
snmp.send(pdu, target, null, listener);
}
}
*******************************************
merci de me donner la solution parce que sa fait un mois que je suis bloquée a ce stade la
merci

mais après avoir effectuer les modifications le navigateur me renvoie les erreurs suivants
***************************************
HTTP Status 500 -
type Exception report
message
descriptionThe server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: PWC6033: Unable to compile class for JSP
PWC6199: Generated servlet error:
string:///index_jsp.java:6: package testpackage does not exist
PWC6197: An error occurred at line: 20 in the jsp file: /index.jsp
PWC6199: Generated servlet error:
string:///index_jsp.java:63: cannot find symbol
symbol : variable test
location: class org.apache.jsp.index_jsp
note The full stack traces of the exception and its root causes are available in the Sun Java System Application Server 9.1_02 logs.
Sun Java System Application Server 9.1_02
*******************************************************************
et moi je suis débutant dans java et c la première foix que je travaille avec java
merci encore une foix pour votre aide nasix
L'erreur est bien marquée, " package testpackage does not exist ", tu importes un package qui n'existe pas. Il va falloir que tu crée un package testPackage (par exemple) dans lequel tu mets ta classe test avant de l'utiliser.
Bonne chance.
j'ai le mm probléme ke toi amine,je vx ke ma classe sera exécuté dans ma page jsp.
j'ai bien importer le package dont il existe
alor là je voulais l'etape suivante
merci