File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes embedded js file in doGet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "embedded js file in doGet" Watch "embedded js file in doGet" New topic
Author

embedded js file in doGet

Kirsten Newbury
Greenhorn

Joined: Nov 12, 2006
Posts: 4
I working with a Tomcat 5.0 server. I use a doGet to send a page back to the client with code like the following:

public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException{

FormatGeneric fg = new FormatGeneric();
PrintWriter out = res.getWriter();
out.println(fg.pageOpen("Welcome to WIC Central"));
out.println("<img src=images/banner.jpg>");
out.println("<script type=text/javaScript src='jsBuildSurvey.js'></script>");
out.println("<form name='login' method='get' action='saveChanges'>");
out.println("<table cols=2>");
out.println("<tr><td><h2>WIC Cost Containment Program</td><td></h2></td></tr>");
out.println("<P><P>");
out.println("<tr><td>Vendor Information and Survey Input</td><td></td></tr>");
out.println("<tr><td>Enter Vendor Id provided:</td><td>");
out.println("</td></tr>");
out.println("<tr><td>Enter Vendor Password provided:</td><td>");
out.println("</td></tr>");
out.println("<tr><td></tr><td>"+fg.formatSubmit("submit", 20, "Login")+"</td></tr>");
out.println("</table>");
out.println("</form");
}

It properly creates the welcome page and displays the banner. The jsBuildSurvey script has a function called saveChanges(). But when I press the logit button, I get a "The page cannot be displayed" error message or a Tomcat message saying /WCCP/saveChanges is not available depending on what I try.

Help? Is my problem in the application web.xml file?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60808
    
  65

Sounss like a client-side debugging issue, so I'm moving this to the HTML forum for futher diagnosis.

Best thing to do (once moved), is to post the View Source of the HTML being sent to the browser.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Kirsten Newbury
Greenhorn

Joined: Nov 12, 2006
Posts: 4
This is the view source.

<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> Welcome to WIC Central</title></head><body bgcolor="white">
<img src=images/banner.jpg>
<script type=text/javaScript src='jsBuildSurvey.js'> </script>
<form name='login' method='get' action='saveChanges'>
<table cols=2>
<tr><td><h2>WIC Cost Containment Program</td><td></h2></td></tr>
<P><P>
<tr><td>Vendor Information and Survey Input</td><td></td></tr>
<tr><td>Enter Vendor Id provided:</td><td>
</td></tr>
<tr><td>Enter Vendor Password provided:</td><td>
</td></tr>
<tr><td></tr><td><input type='submit' name='submit' value='Logit' size='20'></td></tr>
</table>
</form
<P><P><P><P>
<tr><td colspan="2"></td> </tr></table></td></tr> </table></body></html>
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60808
    
  65

Your form action looks suspicious as it lacks any context path.
Kirsten Newbury
Greenhorn

Joined: Nov 12, 2006
Posts: 4
OK, so should action=jsbuildsurvey.savechanges() do the trick? Seems to me the src=jsbuildsurvey should bring in the script similar to an include statement. If that were true, then the savechanges() function ought to be there as part of the page at the client side?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60808
    
  65

"zutrekker",

You have changed your display name from one that is valid to one that is not.

Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Be aware that accounts with invalid display names are removed.

bear
JavaRanch Sheriff
[ November 12, 2006: Message edited by: Bear Bibeault ]
Kirsten Newbury
Greenhorn

Joined: Nov 12, 2006
Posts: 4
I have resolved the problem. It had to do with a conflict in the fg.pageOpen() line. Thank you.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: embedded js file in doGet
 
Similar Threads
Killing session when closing the browser
javax. servlet.Servlet Exception: Initialization failed, Unable to get DB connection
Session tracking
jsp error page is not working
Servlet Problems