File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes How to connect JSP and MS-dos Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "How to connect JSP and MS-dos" Watch "How to connect JSP and MS-dos" New topic
Author

How to connect JSP and MS-dos

Upendra Bhole
Greenhorn

Joined: Dec 05, 2004
Posts: 22
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

Joined: Feb 02, 2002
Posts: 1211

So you dont want any ladies on this forum to help you with that one!!
Upendra Bhole
Greenhorn

Joined: Dec 05, 2004
Posts: 22
Dear Sir/Madam,

Please help me.

Upendra
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
MS DOS does not have IP networking support.


42
Upendra Bhole
Greenhorn

Joined: Dec 05, 2004
Posts: 22
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

Joined: Aug 12, 2004
Posts: 3
Hope this code sample should be useful:

Upendra Bhole
Greenhorn

Joined: Dec 05, 2004
Posts: 22
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to connect JSP and MS-dos
 
Similar Threads
ping IP from JSP page and show result in client's command prompt
IP address of a Unix box
SVN Over Internet
I have no IP address!
How you are recognized/identified over the internet?