简体   繁体   中英

calling jsp page from java class opens it in dreamviewer so how can i open jsp page in eclipse itself?

I have a normal java class which calls JSPpage as soon as control goes to JSP page, the page itself opens in Dreamweaver but I want it to be opened in eclipse itself with its default browser. how can I accomplish this?

This is my code:

String htmlFilePath = "WebContent/raja.
File htmlFile = new File(htmlFilePath);
Desktop.getDesktop().browse(htmlFile.toURI());
Desktop.getDesktop().open(htmlFile);

Do you mean to say you have a simple Java standalone desktop application and not a web-application?

If yes than I would say, JSP's require a servlet-container to be executed.

But by the look of your code it seems that you are not trying to execute but just fetch the JSP which will be fetched just as other files are fetched (like files with extension .html , .txt , .jsp , .php , .doc ).

the page itself opens in Dreamweaver but I want it to be opened in eclipse itself with its default browser

I hope you have read the API for the Desktop#open method, it clearly says:

Launches the associated application to open the file.

If the specified file is a directory, the file manager of the current platform is launched to open it.

So this means if the file you are fetching has .doc extension it would open the file in MS-WORD and if the extension is .txt it might open notepad or any text-editor which is configured as the default associated application.

So it seems the files with .jsp extensions have dreamweaver as the default associated application. So this seems to be a configuration of the underlying platform rather than a code issue.

Currently I don't know if it is possible to change the default associated application for a particular file extension through code dynamically.

This question may also help: How to open a file with the default associated program

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM