This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to connect JSP and MS-dos

 
Upendra Bhole
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Sir,
I am doing one project in which i have to show the ping characteristics on dos prompt.The request will bring the ip from database which i insert for perticular station and that requested IP address will be automatically executed on the ms-dos prompt.
How can i connect to ms-dos to show that ping command on dos.
I am using jsp and sql.
Please help me.

Thanks
Upendra
 
Sonny Gill
Ranch Hand
Posts: 1211
IntelliJ IDE Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So you dont want any ladies on this forum to help you with that one!!
 
Upendra Bhole
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Sir/Madam,

Please help me.

Upendra
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
MS DOS does not have IP networking support.
 
Upendra Bhole
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply

Dear Sir/Madam
I am doing one project in which I have to show ping characteristics of ip address on os command through JSP as a front end.

I have inserted some ip address like 127.0.1.4 in table of sql table.
My JSP page will select the perticular ip from database and it should be automatically display on MS-Dos prompt.
If you give ping 127.0.1.4 on you dos prompt it will disply some characteristics that i want to disply through jsp.
Shall I use bean for this.
Suggest me your valuable output.
Also give me source code for this problem.
I will be very happy for your output.

Thanks ,Regards
Upendra
 
S. Sundar Raman
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hope this code sample should be useful:

 
Upendra Bhole
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi S.Sundar Raman
I am very thankful to you by giving such a valuable output.
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 folloeing code and suggect me in the second 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)
<HTML>
<HEAD>
<center>
<H1>Enter The Station ID<H1>
</HEAD>
<BODY>
<form action="http://localhost:8100/pingip.jsp">
<table border =1 cellpadding=0>
<TR>
<TD><H4>ATM ID :</H4><input type="text" name ="a"></TD>

</TR><BR></table><br>
<INPUT TYPE="submit" value="Ping ATMIP" STYLE="COLOR:BLUE" align = centre>
</center>
</form>
</BODY>
</HTML>

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 dbc:ash","sa","");
Statement st = con.createStatement();
ResultSet rs = st.executeQuery("select atmip from pingip where atmid='"+aip+"'");
Runtime r = Runtime.getRuntime();
Process p = r.exec("ping ");
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 from database table "pingip"
Please suggest me .

Upendra
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic