-
Notifications
You must be signed in to change notification settings - Fork 0
Importing a repository from GitHub and hosting it locally using Glassfish
From IntelliJ's startup window, choose Check Out From Version Control and select Git. If you're signed into GitHub through IntelliJ, the URL should have a dropdown list to choose a repository linked to your account. You can either keep the directory as the default, or change it to something more descriptive to you. Click clone and choose 'yes' when it prompts to create an IntelliJ IDEA project out of the imported project. You can click 'Next' through most, if not all, these setup windows. The only one to really look at is the project SDK, make sure it's your jdk1.8.0_181. Click 'Finish' and onto the next step.
In File > Project Structure, note your various project settings on the left. In 'Project' double check your project has the correct SDK and language level (8), and that there is indeed an output path specified. If one is not specified, create a folder titled 'out' at the highest level of each project module (ex: Project > SimpleServlet > out), then specify it in the 'Project Compiler Output' area of Project Settings.
In 'Artifacts', delete any that may be already there by clicking on them, then clicking the '-' above. Now add a new one by clicking the '+'. Choose one of the first options, which is 'Web Application: Exploded', which will have a right carrot to specify 'From Modules'. Once in this window, choose the module you want to have hosted with Glassfish. Click Apply, then Ok to save your changes.
At the top of your project, where the green arrow to run your project is, there's a spot which says 'Add Configuration...' or if it's already populated, click it and choose 'Edit Configurations'. If there's already a Glassfish server up, delete it by clicking it then clicking the '-' at the top.
Now, click the '+' and choose Glassfish Server, then Local. From here you can give it a name if you want. More importantly, choose the default server domain from the dropdown menu, select your default browser you want it to open in, then click on the Deployment tab at the top.
In this Deployment tab, delete any defaults by clicking them then clicking the '-' at the right side. Now click the '+' and choose 'Artifact...', the one you created should pop in there. Click Apply and Ok. It should now run and open in your selected browser!
In your project tree, navigate to Project > SimpleServlet > src > wctc.edu.simple > SimpleServlet and open it. Click on any red-highlighted word of your choice and push Alt+Enter, choose to Add Java EE6 JARs, then choose the default download option, then Ok. You should now be able to run this project and see it in the browser.
In your project tree, navigate to Project > studentdata > edu.wctc.studentdata. Use Ctrl+click to highlight FindColumns, Individual, and Students, then Ctrl+c to copy. Navigate back to your wctc.edu.simple folder, click it, then Ctrl+v to paste them into it. Click Ok to the first prompt which pops up, but it's ok to ignore the 2nd one about adding to git.
Copy all the Main method's logic within the static void main from line 8 to 32. Paste into the SimpleServlet file after line 24, "out.println(request.getParameter("message"));". Next, delete the "System." part of both "System.out.prinln" commands.
Run the project using your Glassfish server, make sure to click the red stop button beforehand if you have it already running. You should get a page called Simple Servlet which has a hyperlink to Simple Site. You'll see unformatted output that you can mess with using HTML tags in the SimpleServlet file!