Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

How to connect JSP and MS-Dos

Dear Treshr,
I have wrote some code as below.


The code you have given in that the ip to be ping is hard coded.But actually I want to make it as variable,
See the following code and suggect me in the second jsp(pingip.jsp) what i have to change.


First I made the table name pingip

1)
select * from pingip
atmid name atmip routerip
------ ------ -------- ----------
S1AC0635 abc 198.24.37.7 198.24.37.7
S1AN0631 abc1 187.25.16.2 187.25.16.2
2)


Enter The Station ID





ATM ID :











3)

<%@page import="java.io.*"%>
<%@page import="java.sql.*"%>
<%@page import="java.lang.*"%>
<%
String aip = request.getParameter("a");
response.setContentType("text/plain");
try{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc. odbc:ash","","");
Statement st = con.createStatement();
ResultSet rs = st.executeQuery("select atmip from pingip where atmid='"+aip+"'");
Runtime r = Runtime.getRuntime();
Process p = r.exec("ping 198.24.37.7");
InputStream ins =p.getInputStream();
BufferedReader br = new BufferedReader(new InputStreamReader(ins));
String s = br.readLine();
while(s != null)
{
out.println(s);
System.out.println(s);
s = br.readLine();
}

con.close();
}//end of try



catch(SQLException eb)
{
out.println(eb.getMessage());
}//end of catch
catch(Exception ea)
{
out.println(ea.getMessage());
}//end of catch


%>

From First jsp I will put in the textbox atm id S1AC0635.Now if i want to ping ip 198.24.37.7 what could be the change in my sencond jsp especially in

Process p = r.exec("ping ");
So that I can ping any ip of "atmip" column from database table "pingip"
Please suggest me .

Upendra

Sign In or Register to comment.