简体   繁体   English

从java类调用jsp页面在dreamviewer中打开它,那么如何在eclipse中打开jsp页面呢?

[英]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. 我有一个普通的java类,一旦控制进入JSP页面就调用JSPpage,页面本身在Dreamweaver中打开,但我希望它在eclipse本身用它的默认浏览器打开。 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? 您的意思是说您有一个简单的Java独立桌面应用程序而不是Web应用程序吗?

If yes than I would say, JSP's require a servlet-container to be executed. 如果是,我会说,JSP需要一个servlet容器来执行。

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 ). 但是看看你的代码看起来你似乎没有尝试执行,只是获取将被提取的JSP,就像获取其他文件一样(例如扩展名为.html.txt.jsp.php.doc .php ) )。

the page itself opens in Dreamweaver but I want it to be opened in eclipse itself with its default browser 页面本身在Dreamweaver中打开,但我想在eclipse本身使用默认浏览器打开它

I hope you have read the API for the Desktop#open method, it clearly says: 我希望您已经阅读了Desktop#open方法的API,它清楚地说:

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. 因此,这意味着如果您要获取的文件具有.doc扩展名,则它将以MS-WORD打开该文件,如果扩展名为.txt则可能会打开notepad或任何配置为默认关联应用程序的文本编辑器。

So it seems the files with .jsp extensions have dreamweaver as the default associated application. 因此,带有.jsp扩展名的文件似乎将dreamweaver作为默认的关联应用程序。 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 此问题也可能有所帮助: 如何使用默认关联程序打开文件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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