473,396 Members | 1,722 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

problem including .js using Java web server

mickey0
142 100+
hello,
I'm writing my own web server that take a query and respond with the page;
It seems OK. FF nothing console errors.
Problem is when I tried to include in my file html a file "javas.js": FF gets strange error as:
Expand|Select|Wrap|Line Numbers
  1. Error: missing ; before statement
  2. Source Code: http://localhost/javas.js
  3. Row: 1, Column: 5
  4. Source Code:
  5.  200 Document Follows
  6.  
I tried to do javas.js empty: the same error: where can be the error?
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <script language="javascript" src="javas.js"> </script> //without this all is ok
  4. <script>
  5. function myFunc () {
  6.        for (var i=0; i < 100; i++) {
  7.             var table = document.getElementById("intro");  
  8.             var row = document.createElement("tr");
  9.             var cell = document.createElement("td");
  10.             var link = document.createElement("a");    
  11.             link.setAttribute("href", "http://www.google.com");
  12.             var linkText = document.createTextNode(" HI ");     
  13.             link.appendChild(linkText);
  14.             cell.appendChild(link);
  15.             row.appendChild(cell);
  16.             table.appendChild(row);        
  17.     }
  18. }   
  19. </script>
  20.  
  21.  </head>
  22.  <body onload="myFunc()">
  23.     <table style="width: 100%" border="5" >
  24.        <tr><td>  Rsult </td> </tr>
  25.         <tbody id="intro"> </tbody>
  26.     </table>
  27. </body>
  28. </html>
  29.  
However: the content in the page appear properly (only I'd like include a js. to do other thing)

thanks
Jan 30 '08 #1
10 1447
acoder
16,027 Expert Mod 8TB
Have you got script tags within the JavaScript file?
Jan 31 '08 #2
mickey0
142 100+
sorry, I don't know what you mean; script tags inside js file? like as <script> </script>; if you mean this, no i haven't it, only javascript code. Why?
But the problem is that the server don't display properly th page whenever I have the "line" that include include that file (it doesn't work even if the file is empty)
Jan 31 '08 #3
acoder
16,027 Expert Mod 8TB
Yes, that's what I meant. That could possibly have been the cause of this error.

When you have the error on row 1, column 5, what are the contents of the JS file?
Jan 31 '08 #4
mickey0
142 100+
sorry I forget...The page is displayed properly on local. The problem arise only when i lauch my web server and those strange errror occur....It seems that with this web server I can't include external file.....
Jan 31 '08 #5
acoder
16,027 Expert Mod 8TB
Which web server software are you using?
Jan 31 '08 #6
mickey0
142 100+
Which web server software are you using?
I using this minimal
http://www.cafeaulait.org/books/jnp3...TTPServer.java
Repeat: it works with html without .js. Maybe any changes has to do? thanks.
Jan 31 '08 #7
acoder
16,027 Expert Mod 8TB
I've copied this thread to the Java forum. Hopefully you'll get help with possibly modifying the Java code.
Jan 31 '08 #8
r035198x
13,262 8TB
What's the output with


Expand|Select|Wrap|Line Numbers
  1.  <html>
  2. <head>
  3. <script language="javascript" src="javas.js">  //without this all is ok
  4. <script language="javascript">
  5. function myFunc () {
  6.        for (var i=0; i < 100; i++) {
  7.             var table = document.getElementById("intro");  
  8.             var row = document.createElement("tr");
  9.             var cell = document.createElement("td");
  10.             var link = document.createElement("a");    
  11.             link.setAttribute("href", "http://www.google.com");
  12.             var linkText = document.createTextNode(" HI ");     
  13.             link.appendChild(linkText);
  14.             cell.appendChild(link);
  15.             row.appendChild(cell);
  16.             table.appendChild(row);        
  17.     }
  18. }   
  19. </script>
  20.  
  21.  </head>
  22.  <body onload="myFunc()">
  23.     <table style="width: 100%" border="5" >
  24.        <tr>  Rsult  
  25.         <tbody id="intro"> 
  26.     </table>
  27. </body>
  28. </html>
Jan 31 '08 #9
mickey0
142 100+
Nothing change with your hint; I think it a server problem (not of my page)
when that server start the javas.js file isn't find; In fact I tried to put the javascript code into .js and (always with the server on), the error on console is that it can't find myFunc() definition.....(repeat to note: if I delete line that include javas.js and put every javascript code into html, it works).Do anyone know how start that server?
I launch it as: java -jar server.jar mypage.html
At the moment my html is changed to keep it transitional:
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml" >
  4.  
  5. <head>
  6. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  7. <title> home </title>
  8. <script type="text/javascript" src="javas.js"></script>
  9.  
  10. <script type="text/javascript">
  11. /* <![CDATA[ */
  12. function myFunc () {
  13.        for (var i=0;i<100;i++) {
  14.             var table = document.getElementById("intro");  
  15.             var row = document.createElement("tr");
  16.             var cell = document.createElement("td");
  17.             var link = document.createElement("a");    
  18.             link.setAttribute("href", "http://www.google.com");
  19.             var linkText = document.createTextNode(" HII ");     
  20.             link.appendChild(linkText);
  21.             cell.appendChild(link);
  22.             row.appendChild(cell);
  23.             table.appendChild(row);        
  24.     }
  25. }   
  26. /* ]]> */
  27. </script>
  28.  </head>
  29.  
  30. <body onload="myFunc()">
  31.     <table style="width: 100%" border="5" >
  32.         <thead><tr><td> Home Page </td> </tr></thead>
  33.         <tbody id="intro"><tr><td> </td></tr> </tbody>
  34.     </table>
  35. </body>
  36. </html>
  37.  
Jan 31 '08 #10
mickey0
142 100+
Does anyone know how run and use this server?
Jan 31 '08 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Roy Benjamin | last post by:
I'm developing a WEB service for Sun ONE deployment (AppServer7). I'm developing on Windows XP Pro though will deploy on Solaris, Sun AppServer7 includes a XercesImpl.jar in share/lib. 2 kb...
57
by: Xarky | last post by:
Hi, I am writing a linked list in the following way. struct list { struct list *next; char *mybuff; };
4
by: yaron | last post by:
Hi, I have a problem when sending data over TCP socket from c# client to java server. the connection established ok, but i can't send data from c# client to java server. it's work ok with...
34
by: Simon Wigzell | last post by:
document...focus() will scroll the form to move the specified text field into view on everything I have tried it with except Safari on the MAC. The form doesn't move. Any work around? Thanks.
0
by: NoaGross | last post by:
Hi, I'm relly new in java and I have a problem. I'm using java applet. When using http all ok, but when trying to use https i get: Java Plug-in 1.5.0_10 Using JRE version 1.5.0_10 Java...
16
by: Eric | last post by:
I have a user of a web application written in Java/JSP that is unable to login to the site simply because certain links on the page do not run when they are clicked. Other popups using Javascript...
3
by: akmkat | last post by:
Hi all, I am in a great problem. I am trying to implement a multithreaded server using java, first look at the code... /*------- Main Server (server.java)--------------*/ import java.io.* ;...
0
by: shaileshkumar | last post by:
hi, iam unable to run my applications in netbeans4.1. problem may be due to JVM or port numbers conflict. i did not intentionally change any port numbers . please guide me accordingly. iam...
1
by: sethupnr | last post by:
when i'm using a simple JSP-mysql code it shows some HTTP status 500 error.But simple JSP program without databse is running , Please help how to solve this problem. I'm new to JSP. my...
0
by: akaley | last post by:
Hi All, Iam using MultiPartRequest class(cos.jar) for Reading the file comtent from Client Machine. My coding is working without any problem in My local system.But in testing server it causes...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.