facebook

JavaScript debugger not working when app uses Struts

  1. MyEclipse Archived
  2.  > 
  3. Web 2.0 / AJAX
Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #244103 Reply

    John Leveille
    Participant

    I have an application that uses struts. So I have a URL like

    /myapp/home.do

    But then I have some JavaScript in {project}/web/home.jsp (which is the view for the URL home.do). I have tried to debug this javascript, but the debugger never stops on the break points.

    If I move the HTML + JavaScript into a .html file where the URL in the browser

    home.html

    matches the file in the project

    home.html

    the debugger begins working. Is there a problem with the debugger detecting that it should stop when the address line does not match the file name?

    Also, is there any documentation for the debugger? I have only found it discussed on the “what’s new” pages. I found nothing in the help off the Eclipse help menu.

    Thanks!

    #244118 Reply

    Greg
    Member

    Currently the debugger will only stop for breakpoints in javascript and html files. JSP and other dynamic files will be support in future releases but we are still working on that. Many appservers don’t preserve line number entirely correct when trying to map to javascript source. So that is still in progress.

    However you should be able to debug javascript in your struts page by placing all of your javascript in an external .js file and then just linking it into your page with script tag:

    <script type="text/javascript" src="file.js"></script>

    Also, regarding documentation, take a look at the JavaScript Development and Debugging quickstart.
    http://www.myeclipseide.com/images/tutorials/me_remote_doc/javascript/
    This document should also be in the MyEclipse Help integrated into our product.

    The quickstart goes over many of the current features. However it doesn’t show debugging a deployed webapplication but the process if very similar to that of local html files. Just type in the URL.

    #245678 Reply

    Adding <script language=”javascript” src=”js/common.js” charset=”UTF-8″></script> to our jsp file still does not cause myeclipse to stop at breakpoints in common.js. But breakpoints in the Java code in the jsp file our recognized. Running against Tomcat 5.5.

    Any other ideas?

    #246053 Reply

    Riyad Kalla
    Member

    Warren,
    I tried to duplicate your problem and was unable to, please have a look at my demo application here and see if I did what you were talking about. I created an action forward for home.do to home.jsp. I also duplicated the page into home.html. Then I tried debugging the Javascript with it IN the page (in the header) for all 3 types (.do, .jsp, .html) and it worked. Then I created an external file and put the JS in there, and set a breakpoint and commented out the JS from the pages and then tried debugging all 3 types again and it worked there as well.

    Can you try and reproduce my steps and set a breakpoint on the line inside the statement that sets the color?

    #246233 Reply

    Thank you for your response. If I right click on your html file and execute via javascript debugger, I can set breakpoints that work.

    However, now I must show my ignorance. We have a pretty large build procedure for generating and deploying things for our app which was imported awhile some time ago from JBuilder. So, I have not been able to figure out how to build/deploy/invoke a .do file from your .jsp file in order to test the javascript debugging. (I currently have tomcat 5.5, but could use jboss, or …) Would you give me the steps I need to do that. Many thanks for your patience and assistance in helping me understand more of Eclipse/Myeclipse capabilties for what should be a simple thing for me to do.

    #246235 Reply

    Riyad Kalla
    Member

    .do is the extension mapped to struts, you just type it into your browser. You can then see where that will take you by viewing the struts-config.xml file. For example /home would be accessed using /home.do

    The server see’s the .do extension, goes “Oh that’s mapped to ActionServlet” and hands it off to Struts. Then Struts rips the .do off of it, looks at it, /home, and checks the struts-config.xml file for a match, finds it, and sends the user there. In this case, the home.jsp file.

    #246239 Reply

    Thanks. I guess I knew that, but somehow did not do it.

    I can set breakpoints in your rollover.js file in the project directory, but cannot set breakpoints in the rollover.js file in the deployment directory which is where I suspect they need to be set. What am I missing?

    #246254 Reply

    Riyad Kalla
    Member

    Thanks. I guess I knew that, but somehow did not do it.

    Keeping all this stuff straight is a full time job.

    I can set breakpoints in your rollover.js file in the project directory, but cannot set breakpoints in the rollover.js file in the deployment directory which is where I suspect they need to be set. What am I missing?

    You shouldn’t be worried about the deployment directory. Just set breakpoints in the files in your project, when you debug it, part of the communication between the server and MyEclipse that takes place tells MyEclipse *where* you are in the execution, so MyEclipse can break for you at those points.

    It’s all a lot of black magic 🙂

Viewing 8 posts - 1 through 8 (of 8 total)
Reply To: JavaScript debugger not working when app uses Struts

You must be logged in to post in the forum log in