36
Creating a new Web Application project targeting GlassFish Server Criando um novo projeto Web Application Server GlassFish segmentação With the File | New | rojects!!! menu item" #ind the $%&namic Web roject$ categor& to create a new Web Application! 'nter a roject Name in the #irst #ield( )&FirstWebApp! Notice that the $GlassFish v* relude$ +arget ,untime is selected! -# not" use the combo.bo/ to select it! +his will add all the necessar& jar #iles in the project path so that &ou can compile with selected 0ava '' A-s!0ust use the de#ault settings #or now and select the $Finish$ button! Criando um novo projeto Web Application Server GlassFish segmentação Com o | Novo Aruivo | !rojetos """ item de menu# locali$e o %&'namic Web !roject categoria% para criar uma nova Web Application" (ntrodu$a um nome do projeto no primeiro campo) *'FirstWebApp" +bserve ue o %GlassFish v, !relude% -arget .untime / selecionado" Se não# use a cai0a de combinação para selecion12lo" (sto ir1 adicionar todos os aruivos jar necess1rios no caminho do projeto de modo ue voc3 pode compilar com 4ava 55 selecionadas A!(s"4usto usar as con6iguraç7es padrão para agora e selecione o botão %Finish%"

Criando+um+novo+projeto+Web+Application+Server+GlassFish+segmentação

Embed Size (px)

Citation preview

Creating a new Web Application project targeting GlassFish Server

Criando um novo projeto Web Application Server GlassFish segmentaoWith the File | New | Projects... menu item, find the "Dynamic Web Project" category to create a new Web Application.

Enter a Project Name in the first field: MyFirstWebApp.Notice that the "GlassFish v3 Prelude" Target Runtime is selected. If not, use the combo-box to select it. This will add all the necessary jar files in the project path so that you can compile with selected Java EE APIs.Just use the default settings for now and select the "Finish" button.

Criando um novo projeto Web Application Server GlassFish segmentao Com o | Novo Arquivo | Projetos ... item de menu, localize o "Dynamic Web Project categoria" para criar uma nova Web Application.Introduza um nome do projeto no primeiro campo: MyFirstWebApp.Observe que o "GlassFish v3 Prelude" Target Runtime selecionado. Se no, use a caixa de combinao para selecion-lo. Isto ir adicionar todos os arquivos jar necessrios no caminho do projeto de modo que voc pode compilar com Java EE selecionadas APIs.Justo usar as configuraes padro para agora e selecione o boto "Finish".

The project is now created and visible in the Project Explorer view. The GlassFish plugin creates a default index.jsp page and opens it in the JSP editor.O projeto agora est criado e visvel na exibio Project Explorer. O plugin GlassFish cria uma pgina index.jsp padro e abre no editor JSP.OuvirLer foneticamente

Select the "Run" Menu or toolbar icon, and pick the "Run On Server" option. Select GlassFish as the server you want to run this application (You can select the "Always use this server when running this project" check box to streamline further run invocations.Selecione a opo "Executar" do menu ou cone da barra de ferramentas, e escolher o "Run On Server" opo. Selecione GlassFish como o servidor que voc deseja executar este aplicativo (Voc pode selecionar a opo "Sempre usar este servidor durante a execuo deste projeto" caixa de seleo para agilizar ainda mais as invocaes de execuo.

The Web application is then deployed to GlassFish v3 Prelude, as shown in the server log (it took 100ms to deploy), and the index.jsp page appears in the Eclipse default Web Browser.You can now switch back and forth between the index.jsp editor and the Web Browser view. Each time you save the JSP, the application is redeployed on Save, and you can reload the page (small yellow icon on the Browser view) to see the changes immediately.O aplicativo da Web ento implantado GlassFish v3 Prelude, como mostrado no log do servidor (que levou a implantar 100ms), e na pgina index.jsp aparece no padro Eclipse Web Browser.Agora voc pode alternar entre o editor e o index.jsp vista Web Browser. Cada vez que voc salvar o JSP, o pedido novamente em Salvar, e voc pode recarregar a pgina (pequeno cone amarelo na tela do browser) para ver as alteraes imediatamente

Changing Global Preferences for the GlassFish Server

The GlassFish Plugin for Eclipse has some global preferences you can tweak. Use the "Preferences" Menu item and select the GlassFish Preferences category:Alterar Preferncias Global para o servidor GlassFishO GlassFish Plugin para o Eclipse tem algumas preferncias globais que voc pode puxar categoria. Use o item "Preferncias" e selecione o menu Preferncias GlassFish:OuvirLer foneticamente

Dicionrio - Ver dicionrio detalhadoTraduza qualquer site

Los Angeles Times-Estados Unidos

La Informacin-Espanha

Guardian.co.uk-Reino Unido

Yomuiri Online-Japo

Sueddeutsche.de-Alemanha

Louvre-Frana

Vogue-Frana

Machu Picchu-espanhol

Zeit Online-Alemanha

Gotujmy.pl-polons

Arte Toreo-Espanha

Spiegel Online-Alemanha

Using the "GlassFish Preferences" category, you can modify the following flags:

Enable GlassFish Plugin Log information in IDE log file

This is more for the plugin debugging purpose than anything else. Turn on this option to see additional traces in the Eclipse log file specific to the GlassFish Plugin. This option is OFF by default.

Start the JavaDB database process when Starting GlassFish Server

GlassFish Server includes Java DB Database and this option allows you to start it automatically when the server is started. It is very convenient to do when you work with JPA applications. The options is ON by default.

Start the GlassFish Enterprise Server in verbose mode (Eclipse console can be used)

Using this flag will send all the output log of the Server inside the Eclipse console as well. This options is OFF by default as there is a GlassFish specific log view.

Enable colored rendering in the GlassFish Log Viewer

For color blind people, you can turn this option OFF. Otherwise, INFO level messages will be black, WARNING messages will be yellow, SEVERE messages will be red, and multiple line entries will be Italic. Parte superior do formulrio

Digite um texto ou endereo de um site ou traduza um documento. Usando o Preferences "GlassFish categoria", voc pode modificar as seguintes bandeiras: Habilitar GlassFish Plugin informao Entrar IDE arquivo de logEste o mais para o plugin depurao de finalidade que outra coisa. Ligue esta opo para ver os traos adicionais no log do Eclipse arquivo especfico para o plugin GlassFish. Esta opo est desligada por padro. Iniciar o processo de banco de dados JavaDB ao iniciar GlassFish ServerGlassFish Server inclui o Java DB Database e esta opo permite que voc inici-lo automaticamente quando o servidor iniciado. muito conveniente que fazer quando voc trabalha com aplicaes de JPA. As opes por padro ON. Comece o GlassFish Enterprise Server no modo verbose (Eclipse console pode ser usada)o Usando este pavilho vai enviar todos os log a sada do servidor dentro da Eclipse console tambm. Esta opo est desligada por padro como h uma viso log GlassFish especficos. Ativar renderizao de cor no GlassFish Log ViewerPara o povo cego cor, voc pode desligar essa opo. Caso contrrio, as mensagens de nvel INFO vai ser preto, as mensagens de advertncia ser amarela, mensagens graves sero vermelhas, e vrias entradas de linha ser em itlico.

Using the Help menu for GlassFish

You have access to all the Online Documentation books for GlassFish v2 and GlassFish v3 Prelude via the Eclipse Help menu, under the "GlassFish Enterprise Server" menu item. Pleas take the time to read these official documents for learning how to use, administer or deploy with the GlassFish server. These books are opened in the Eclipse default Web Browser.

You can also get to the GlassFish Enterprise Server Support page easily from there.

Usando o menu Ajuda para GlassFishVoc tem acesso a todos os livros documentao on-line para GlassFish v2 e GlassFish v3 Prelude, atravs do menu Help do Eclipse, sob o item de menu "GlassFish Enterprise Server". Fundamentos ter tempo para ler os documentos oficiais para aprender a usar, administrar e implantar com o servidor GlassFish. Estes livros so abertos no padro Eclipse Web Browser.

Voc tambm pode acessar a pgina de suporte GlassFish Enterprise Server facilmente de l

TCP/IP Monitoring Web Applications with GlassFish

TCP/IP monitoring a nice Eclipse feature that is enable for the GlassFish application server. It allows to trace HTTP requests made to your web application. You need first to configure the monitoring by selecting the server popup menu item named "Monitoring | Properties" as below:TCP / IP Monitoramento de Aplicaes Web com GlassFishTCP / IP monitoramento de um recurso do Eclipse que bom para habilitar o servidor da aplicao GlassFish. Ele permite rastrear as solicitaes HTTP feitas ao seu aplicativo web. Voc primeiro precisa configurar o acompanhamento, selecionando o item de menu pop-up do servidor chamado "Observatrio | Propriedades", como abaixo:

In the Monitoring properties, select the "Add..." button on the right side:Nas propriedades de acompanhamento, selecione a opo "Add ..." boto do lado direito:

And select the "Server Port" which is the http port used by the GlassFish server. In our case, it is 8080. The port that will be used to actually do the monitoring is 8081 as specified in the Monitor Port field. (Change this port as you need).E selecione a opo "Server Port", que a porta HTTP usada pelo servidor GlassFish. No nosso caso, 8080. A porta que ser usada para realmente fazer o acompanhamento 8081, conforme especificado no campo Port Monitor. (Alterar esta porta que voc precisa).

Last step to do is to click on the "Start" button on the right side to start the monitoring on the port 8080 via the port 8081:O ltimo passo a fazer clicar no boto "Iniciar" do lado direito para iniciar o acompanhamento sobre a porta 8080 atravs da porta 8081:

You should see a "Started" status in the Status column. You are now all set to play with the monitoring feature.Select "Apply" button and "OK".Voc dever ver um status "Iniciado" na coluna Status. Agora voc est pronto para jogar com o recurso de monitoramento.Selecione "Aplicar" e "OK".

Now, assuming the GlassFish server is started, access a web page using the port 8081 instead of the regular port 8080.The TCP/IP monitor view should appear below, and fill up with the traffic between your Web browser and your web application. When you select each request in the tree at the top left, information about the request/response is shown, the bottom left of the view will display the HTTP request that was made to your web application, and the bottom right will show each response.Agora, supondo que o servidor GlassFish iniciado, aceder a uma pgina web usando a porta 8081 em vez de regular a porta 8080.O TCP / IP vista monitor deve aparecer abaixo, e preencher com o trfego entre o seu navegador Web e sua aplicao web. Quando voc seleciona cada solicitao da rvore no canto superior esquerdo, as informaes sobre o pedido / resposta mostrado, no canto inferior esquerdo da exibio ir mostrar a solicitao HTTP que foi feito para sua aplicao web, e no canto inferior direito ir mostrar a cada resposta.

Adding a Servlet and using Session Preservation feature

Select the New Servlet category to create a new Servlet. Enter a package name (apkg for example), and a servler name (MyServlet for example).Adicionando um Servlet e usar Session recurso PreservaoSelecione a categoria New Servlet para criar um Servlet novo. Digite um nome de pacote (apkg por exemplo), e um nome servler (MyServlet por exemplo).

In the Eclipse editor, add more logic to your servlet.As an example of a servlet code dealing with Sessions, you can use the source content for the MyServlet.java. You can copy paste most of the code.Save your servlet file, and go the to Browser window to activate the servlet page (http://localhost:8080/MyFirstWebApp/MyServlet). You should see something similar to:No editor Eclipse, adicione mais lgica para o servlet.Como exemplo de um cdigo servlet lidar com Sessions, voc pode usar a fonte de contedo para o MyServlet.java. Voc pode copiar e colar a maior parte do cdigo.Salve o arquivo servlet, e v para a janela do navegador para ativar o servlet de pgina (http://localhost:8080/MyFirstWebApp/MyServlet). Voc deve ver algo semelhante a:

Reload the serlvet web page a few times: you'll see the Number of Previous Accesses field growing (as seen above, we clicked 4 times on the page). This counter is stored in the Servlet Session data. We want now to modify the Servlet source code, and redeploy the web application to GlassFish v3 Prelude (remember, by default, the "Deploy On Save" mode is enable, so you just need to save the servlet source file and go the browser page and click the reload button to see the updated page.

In our test we just add some text in the servlet as shown below: (Update Servlet!!!)Recarregue a pgina web serlvet algumas vezes: voc ver o nmero de acessos campo anterior crescente (como visto acima, clicamos 4 vezes na pgina). Este contador armazenado nos dados Session Servlet. Queremos agora para modificar o cdigo-fonte Servlet e reimplantar o aplicativo web para o GlassFish v3 Prelude (lembre-se, por padro, o "modo de implementar em Save" permitir que, por isso voc s precisa salvar o arquivo servlet-fonte e ir a pgina do browser e clique no boto Atualizar para ver a pgina atualizada.

Em nosso teste, basta adicionar algum texto no servlet como mostrado abaixo: (Update Servlet!)

See the update page: the servlet has been redeployed, we see the (Update Servlet!!!) change we did in the source editor, and the field "Number of Previous Accesses" is now 5, meaning that the Servlet Session Data was preserved during redeployment.This is a very coo feature for GlassFish v3 Prelude, critical when you are developing/debugging complex Web Applications with complex Session management (Shopping Cart,...) and you want to keep the information of your Sessions across redeployments.

Veja a pgina de atualizao: o servlet foi reimplantado, vemos o (Update Servlet!) Mudana que fizemos no editor de cdigo, e no campo "Nmero de Acessos anterior" agora 5, significando que o Servlet sesso de dados foi preservada durante a readaptao.Esta uma caracterstica muito coo para GlassFish v3 Prelude, crtica quando voc est desenvolvendo / depurao de aplicaes complexas da web com gesto de sesso complexos (carrinho ,...) e quiser manter as informaes de suas sesses atravs de reafectaes.

Using the Debugger to debug a Servlet with GlassFish

You can set breakpoints on any Java class (servlet, helper classes, JPA, Web Services,...) of a Web Application, or on JSP pages (which contain Java code fragments), using the popup menu available in the vertical grey bar of the Eclipse Editor (on the left side), and selecting the first menu item named "Toggle BreakPoint". If Eclipse can set up a break point on this selected line, a small icon will appear on the bar. Otherwise, Eclipse will notify that a breakpoint cannot be set on this line (For example, in HTML fragments of a JSP file).

Usando o depurador para depurar um Servlet com GlassFishVoc pode definir pontos de interrupo em qualquer classe Java (servlet, classes auxiliares, JPA, Web Services ,...) de um aplicativo da Web ou em pginas JSP (que contm fragmentos de cdigo Java), usando o menu popup disponvel na barra vertical cinza Editor do Eclipse (no lado esquerdo), e selecionar o primeiro item de menu chamado "Alternar ponto de interrupo". Se Eclipse pode criar um ponto de equilbrio nessa linha selecionada, um pequeno cone aparecer na barra. Caso contrrio, o Eclipse ir notificar que a interrupo no pode ser definido nesta linha (por exemplo, em fragmentos de HTML de um arquivo JSP).

Once a breakpoint is declared, and that GlassFish server has been started in debug mode via the Servers views "Debug" button, Eclipse will swich to the Debug Perspective as soon as you activate a Web Page where a break point has been set:Depois de um ponto de interrupo declarada, e que o servidor GlassFish foi iniciado no modo de depurao atravs do Servidores vista "Debug" boto, o Eclipse vai swich s Perspectivas Debug logo que voc ativar uma pgina da Web onde um ponto de interrupo foi definido:OuvirLer foneticamente

Dicionrio - Ver dicionrio detalhadoTraduza qualquer site

Los Angeles Times-Estados Unidos

La Informacin-Espanha

Guardian.co.uk-Reino Unido

Yomuiri Online-Japo

Sueddeutsche.de-Alemanha

Louvre-Frana

Vogue-Frana

Machu Picchu-espanhol

Zeit Online-Alemanha

Gotujmy.pl-polons

Arte Toreo-Espanha

Spiegel Online-Alemanha

You can now use the feature-rich Eclipse debugger on you Web Applications or Java EE applications running on the GlassFish Application Server.

Viewing the GlassFish Admin Console from Eclipse

There are many administrative features you cannot perform with the Eclipse IDE. but are available via the GlassFish Admin Console accessible from the IDE. The Admin console can be launched using the GlassFish entries in the GlassFish popup menu on the GlassFish server node. It takes a few seconds to start, so please wait until the page is fully initialized:

Agora voc pode usar o recurso-rich debugger do Eclipse em suas aplicaes Web ou aplicaes Java EE rodando no GlassFish Application Server.

Vendo o GlassFish Admin Console do Eclipse

H muitos recursos administrativos no possvel executar com o IDE Eclipse. mas esto disponveis atravs do Admin Console do GlassFish acessvel a partir do IDE. O console de administrao pode ser iniciado usando as entradas do GlassFish no menu pop-up GlassFish no n do servidor GlassFish. Demora alguns segundos para iniciar, por favor aguarde at que a pgina totalmente inicializado:

Here is the view of a fully functional GlassFish Administration Console running in the Eclipse default Web Brower. Of course it assumes that the GlassFish server is up and running.Aqui est a viso de um totalmente funcional GlassFish Administration Console funcionando no padro do Eclipse Web Brower. claro que ele assume que o servidor GlassFish estiver instalado e funcionando.

Using the GlassFish v3 Prelude Update Center from EclipseUsando o GlassFish v3 Prelude Update Center do Eclipse

Registrating your GlassFish installationO registro de sua instalao do GlassFish

Adding a new Data Source and registering it to GlassFish

Adicionando uma nova fonte de dados e registr-lo para GlassFish