import java.net.*; import java.io.*; public class sample { public static void main (String args[]) { String line; try { URL url = new URL( "http://localhost:8080/WeighPro/CommPortSample" ); BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream())); line = in.readLine(); System.out.println( line ); in.close(); } catch (Exception e) { System.out.println("Hello Project::"+e.getMessage()); } } }
我的Servlet正在调用另一个Jsp页面,如下所示,
RequestDispatcher rd=request.getRequestDispatcher("index.jsp"); rd.forward(request, response);
我没有在浏览器中得到任何反应/输出,浏览器一旦被调用就必须在其中执行。
我是否缺少此过程的任何基本步骤?请帮忙!!!
如果要在浏览器中打开它,请尝试此操作
java.awt.Desktop.getDesktop().browse(java.net.URI.create("http://localhost:8080/WeighPro/CommPortSample"));