Go Back   CodingForums.com > :: Server side development > Java and JSP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-18-2012, 09:14 AM   PM User | #1
direct_tarun
New to the CF scene

 
Join Date: Dec 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
direct_tarun is an unknown quantity at this point
can't view my page only URL is showing in the address bar

hello everyone i have to show a page index.jsp and in this page i have used the onload submit
Code:
<script type="text/javascript">
		function myfunc () {
		var frm = document.getElementById("my_form");
		frm.submit();
		}
		window.onload = myfunc;
	</script>
<form id="my_form" action="tempmonitor" method="post">
the above is my jsp code and i have printed hello on this page. But when i hit the URL localhost:8090/tempmonitoringsystem/index.jsp. It shows index.jsp for nanosec den went away to the folowing URL localhost:8090/tempmonitoringsystem/tempmonitor and i don't know where it is redirecting to. I am Attaching my servlet code as well as xml code.

Code:
 TempMonitorServlet.java
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
		throws ServletException, IOException {
		System.out.println("hello world");
		String path = "E:\\"; 
		 
		  String files;
		  File folder = new File(path);
		  File[] listOfFiles = folder.listFiles(); 
		 
		  for (int i = 0; i < listOfFiles.length; i++) 
		  {		 
			  if (listOfFiles[i].isFile()) 
			  {
				  files = listOfFiles[i].getName();
				  
				  if (files.endsWith(".txt") || files.endsWith(".TXT"))
				  {
					  System.out.println(files);
					  ReadingFromFile read_file = new ReadingFromFile();
					  
					  String last_line_from_file = read_file.read(files) ;
					  System.out.println("\n"+last_line_from_file);
					  if(last_line_from_file != null)
					  {
						 
						  drawImage(req,resp ,last_line_from_file,files) ;
					  }
				  }
			  }
		  }
}

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
  <display-name>ZigbeeRest</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
  
  <servlet>
        <servlet-name>tempmonitor</servlet-name>
        <servlet-class>
			tempmonitor.TempMonitorServlet
		
        </servlet-class>
        <init-param>
            <param-name>javax.ws.rs.Application</param-name>
            <param-value>com.restful.Zigbee.services.ZigbeeApplication</param-value>
        </init-param>
    </servlet>

    <servlet-mapping>
        <servlet-name>tempmonitor</servlet-name>
        <url-pattern>/tempmonitor</url-pattern>
    </servlet-mapping>
 
</web-app>
direct_tarun is offline   Reply With Quote
Reply

Bookmarks

Tags
java, jsp, servlet

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:05 AM.


Advertisement
Log in to turn off these ads.