wood burning stoves 2.0*
The moose likes IDEs, Version Control and other tools and the fly likes creating website basic question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "creating website basic question" Watch "creating website basic question" New topic
Author

creating website basic question

mahesh matele
Greenhorn

Joined: Jan 23, 2012
Posts: 23
Hi,

i m new to jsp development.

I would like to know a few basic

For, to start development (creating website) in jsp,i have

1) Apache Tomcat server,

i would like to know what are the other softwares required for jsp development.
like
an editor for development ?
Philip Thamaravelil
Ranch Hand

Joined: Feb 09, 2006
Posts: 99
Mahesh,


Are you planning on creating dynamic content? If so, Tomcat works well. You'll also need an IDE to create/develop your webapps (such as Eclipse or Netbeans) and ANT or MAVEN will be helpful in packaging and deploying your code. Of course, you'll want to store/share your code reliably right? So Subversion is one of many good, free source code repositories.

If static content is your requirement, Tomcat is a bit much IMO. Apache HTTP Server would be a much better selection.

Good Luck!
Philip
mahesh matele
Greenhorn

Joined: Jan 23, 2012
Posts: 23
Hi,Thanks for the immediate reply.

Firstly to answer your question.
I m creating a website on java,so i need jsp and servlets and javascriot and html (Please correct me if i m wrong anywhere in the reply.)
i m using tomcat 6 server

Now one of the problems i m facing is .....
i have installed jdk ,tomcat ...i have also set the Classpath,java_home,catalina_home for the said components.
1) i have also tried executing some my created jsp files which i m running from webapps folder. i have also created a XXXX folder on my desktop where im going to store my html and jsp files .But im not able to run these pages from the XXXX folder though same fikes could be run from webapps. I know i need to make an entry of it in the system variables ...But i need a guidance for where i need to add this path.

2) I would like to know if there is a free tool where i can drag and drop components from the palette and an HTML code is generated for it.Also if i can store this HTML code at some other place and execute ? this may save my html code designing time,and i can concentrate on logic.

Please help its urgent.

Philip Thamaravelil
Ranch Hand

Joined: Feb 09, 2006
Posts: 99
mahesh matele wrote:Hi,Thanks for the immediate reply.

Firstly to answer your question.
I m creating a website on java,so i need jsp and servlets and javascriot and html (Please correct me if i m wrong anywhere in the reply.)
i m using tomcat 6 server

Now one of the problems i m facing is .....
i have installed jdk ,tomcat ...i have also set the Classpath,java_home,catalina_home for the said components.
1) i have also tried executing some my created jsp files which i m running from webapps folder. i have also created a XXXX folder on my desktop where im going to store my html and jsp files .But im not able to run these pages from the XXXX folder though same fikes could be run from webapps. I know i need to make an entry of it in the system variables ...But i need a guidance for where i need to add this path.

2) I would like to know if there is a free tool where i can drag and drop components from the palette and an HTML code is generated for it.Also if i can store this HTML code at some other place and execute ? this may save my html code designing time,and i can concentrate on logic.


Please help its urgent.




Well, in order for your JSP's to work, you'll need to execute them in the Tomcat servlet container. The Servlet Container is what parses your JSP code (and does lot's of other things). You execute them in the container by creating a webapp. I'm sure you've seen the ROOT webapps already in the $TOMCAT_HOME/webapps/ directory.

Here's what I can suggest:
1. Create a directory somewhere.. let's say c:\work
2. Download and unzip Eclipse (http://www.eclipse.org/downloads/packages/eclipse-ide-java-developers/indigosr1)
3. Start Eclipse
4. Choose c:\work as your workspace directory ( eclipse will prompt as soon as it starts).
5. In Eclipse select File->New->Dynamic Web Project
6. Give it a name in the new window and click finish.


This will create a new web project in your c:\work directory.. I suggest you review this directory structure and it's contents.
If all you need to do is create a series of JSP's.. You can do this in the WebContent Directory.


Once you've created a few JSP's in the WebContent directory, go ahead and deploy it to tomcat.
How to deploy:
1. Right-Click your project in the project explorer in Eclipse.
2. Export
3. WAR File
4. Select your destination as the $TOMCAT_HOME/webapps/ directory

If you watch your tomcat log files, you'll see the tomcat service unpackage and deploy your new webapp. Obviously this can be automated with ANT. Google "ANT WAR Deployment Tutorial" to learn more.



Cheers,
Philip


mahesh matele
Greenhorn

Joined: Jan 23, 2012
Posts: 23
Hey Philip,

Thanks for the quick reply..

I ll try what you have suggested.Thanks.

I do not know whether this question should be a part of this forum or not but.... i would like to know if there is any tool that automates the html code and has a panel for drag an dropping html components.
And further i can copy this html code and deploy it some other place ?
Philip Thamaravelil
Ranch Hand

Joined: Feb 09, 2006
Posts: 99
mahesh matele wrote:Hey Philip,

Thanks for the quick reply..

I ll try what you have suggested.Thanks.

I do not know whether this question should be a part of this forum or not but.... i would like to know if there is any tool that automates the html code and has a panel for drag an dropping html components.
And further i can copy this html code and deploy it some other place ?




Sure, there are lots of these tools. Eclipse has a package for doing so.. Eclipse Web Tools Platform (this if free). Also, Dreamweaver works well.
Just remember, when you become dependent on these visual editors..sometimes you end up with a spaghetti code that's difficult to manage. Just my two cents.


ANT can automate the process of copying code from one place to the next..Also Linux Shell script, and Windows Batch script can do this as well.


Cheers,
Philip

mahesh matele
Greenhorn

Joined: Jan 23, 2012
Posts: 23
Thanks for the quick reply.

I ll get back to you when i try out some of your above mentioned suggestions. :D
mahesh matele
Greenhorn

Joined: Jan 23, 2012
Posts: 23
Hi,

As you suggested...
i have created my webpages i.e html pages using dreamweaver.
So now i have my webpages

I want to now add jsp code to it

So i have downloaded eclipse indigo jee
I already have tomcat and jdk installed on my system.

Now i need a few tips on how to setup my eclipse with my html created files also how do i run these jsp files ???

Thank you for the help !
Philip Thamaravelil
Ranch Hand

Joined: Feb 09, 2006
Posts: 99
mahesh matele wrote:Hi,

As you suggested...
i have created my webpages i.e html pages using dreamweaver.
So now i have my webpages

I want to now add jsp code to it

So i have downloaded eclipse indigo jee
I already have tomcat and jdk installed on my system.

Now i need a few tips on how to setup my eclipse with my html created files also how do i run these jsp files ???

Thank you for the help !



Did you create an eclipse "Dynamic Web Project"?
mahesh matele
Greenhorn

Joined: Jan 23, 2012
Posts: 23
Hi,


I have given my workspace as some folder e.g C:\ABC which has the files created in HTML in it inside HTML folder and Images inside Images folder.So that is my workspace and i would like to create my JSP inside the same folder.

So now as you have asked,

Yes i have created a WEB PROJECT as i have called it Sample1.

For which the path i have followed is -------> New--->Project-->Web--> Dynamic Web Project

Called the Project as Sample1
I have used Default Location -----> which is the Folder i have mentioned above C:\ABC\Sample1
Chose the run time as Apache Tomcat v6.0
Config as Default Config for Apache v6.0


Now a tree is shown inside my Project Explorer as :

Sample2
+JAX-WS WebServices
+Deployment Descriptor:Sample2
+Java Resources
+JavaScript Resources
+build
-WebContent
+ META-INF
+ WEB-INF


Now how do i bring together my HTML and Images folder file and above mentioned folders ?
Please help !





mahesh matele
Greenhorn

Joined: Jan 23, 2012
Posts: 23
Just to add to the above post............

I copied my folder of HTML files and Images folder and pasted them into the WebContent folder

So now my WebContent folder has

3 folders HTML META-INF and WEB-INF

Also i have created a testResult.jsp which shows data from a form in one of the HTML folders .html files

So now my WebContent folder has

3 folders HTML META-INF and WEB-INF and 1 file which is testResult.jsp

After that i have:

1. Right-Click project in the project explorer in Eclipse.
2. Export
3. WAR File
4. Select as the $TOMCAT_HOME/webapps/ Proj_data

So a Proj_data.war was created

now how do i run this to check if i m getting expected results ??

Philip Thamaravelil
Ranch Hand

Joined: Feb 09, 2006
Posts: 99
mahesh matele wrote:Just to add to the above post............

I copied my folder of HTML files and Images folder and pasted them into the WebContent folder

So now my WebContent folder has

3 folders HTML META-INF and WEB-INF

Also i have created a testResult.jsp which shows data from a form in one of the HTML folders .html files

So now my WebContent folder has

3 folders HTML META-INF and WEB-INF and 1 file which is testResult.jsp

After that i have:

1. Right-Click project in the project explorer in Eclipse.
2. Export
3. WAR File
4. Select as the $TOMCAT_HOME/webapps/ Proj_data

So a Proj_data.war was created

now how do i run this to check if i m getting expected results ??




Sounds like you've made some excellent progress.

So, in order to deploy the project, you need to copy the WAR file into your $TOMCAT_HOME/webapps directory...

If tomcat isn't already running, start it up... (execute $TOMCAT_HOME/bin/startup.bat (or startup.sh if your on linux)..

This will open a command prompt showing all output from tomcat.

Once it finishes starting, go back to your webapps directory. You should see that there is a folder with the same name as your WAR file...

You can access the webapplication via: http://localhost:80080/WAR_NAME

so for example..if you deploy myapp.war to the webapps directory. it will create a folder $TOMCAT_HOME/webapps/myapp which is accessible via browser at http://localhost:8080/myapp/

remember..it's looking for a index.html or index.jsp..so you'll have to type in your test jsp name if it's not named index.xxx

Cheers,
Philip
Philip Thamaravelil
Ranch Hand

Joined: Feb 09, 2006
Posts: 99
mahesh matele wrote:Hi,
Now how do i bring together my HTML and Images folder file and above mentioned folders ?


Your WebContent directory is essentially your web root. Put all of your images, html, css, js within there. You can place JSP's as well.

Any items, that you don't want to be visible directly must go in the WEB-INF directory. For example, it's a common practice to put all your security-sensitive JSP files in the WEB-INF folder. Them must be access via Controller/Servlet/etc.. though.
mahesh matele
Greenhorn

Joined: Jan 23, 2012
Posts: 23
Hi,
Thanks for the reply.Been waiting for it.

So as you said i..

1)exported the project to
C:\Program Files\Apache Software Foundation\Tomcat 6.0\web apps
2)started the server from the task bar
3)A new folder with the same war name got created
4)opened IE and typed http://localhost/BML

I got an error

HTTP Status 404 - /BML/

--------------------------------------------------------------------------------

type Status report

message /BML/

description The requested resource (/BML/) is not available.



So how do i solve this....what is it that is incorrect ??
Philip Thamaravelil
Ranch Hand

Joined: Feb 09, 2006
Posts: 99
mahesh matele wrote:Hi,
Thanks for the reply.Been waiting for it.

So as you said i..

1)exported the project to
C:\Program Files\Apache Software Foundation\Tomcat 6.0\web apps
2)started the server from the task bar
3)A new folder with the same war name got created
4)opened IE and typed http://localhost/BML

I got an error

HTTP Status 404 - /BML/

--------------------------------------------------------------------------------

type Status report

message /BML/

description The requested resource (/BML/) is not available.



So how do i solve this....what is it that is incorrect ??



Is your tomcat instance running on port 80 or port 8080?

The default setting is port 8080...

so your url would be incorrect.

Should be: http://localhost:8080/BML


also, make sure you have your capitalization correct.

Cheers,
Philip
mahesh matele
Greenhorn

Joined: Jan 23, 2012
Posts: 23
When i was setting up Tomcat server there was a setting which when done i don't need to mention it as localhost:8080 every time
I just need to mention localhost and i can see Tomcat successful config page.

So , just writing http://localhost gives me Tomcat successful config page.

So my address i have mentioned is
http://localhost/BML
Philip Thamaravelil
Ranch Hand

Joined: Feb 09, 2006
Posts: 99
mahesh matele wrote:When i was setting up Tomcat server there was a setting which when done i don't need to mention it as localhost:8080 every time
I just need to mention localhost and i can see Tomcat successful config page.

So , just writing http://localhost gives me Tomcat successful config page.

So my address i have mentioned is
http://localhost/BML



You set the http port to 80.

do you have an index.html or index.jsp?
mahesh matele
Greenhorn

Joined: Jan 23, 2012
Posts: 23
Hi i do have an index.html in the below path.


C:\BML\WebContent\HTML\index.html

Can you just quickly guide me on how to change the port to 80 ?
Philip Thamaravelil
Ranch Hand

Joined: Feb 09, 2006
Posts: 99
Your index.html must be in the Webcontent directory. Then redeploy your webapp in eclipse.

You already are using port 80, so no change required.




Cheers
Philip
mahesh matele
Greenhorn

Joined: Jan 23, 2012
Posts: 23
Hi,

Thanks for the reply...

I can now see the index.html

Fine...i guess i have deployed it now, right ?

I ll get back to you if i face any problems !

Thanks for the help!...appreciate it !

Philip Thamaravelil
Ranch Hand

Joined: Feb 09, 2006
Posts: 99
That's terrific! Glad to hear it's working for you.

Cheers,
Philip
mahesh matele
Greenhorn

Joined: Jan 23, 2012
Posts: 23
Hi Philip,

I need some more guidance with my website.

I would like to know ....

1) i want to add some validations to my website elements.

What scripting languages do i need

I have seen a few tutorials using javascript for validations and ajax 2!

Could it done using jsp 2 ?
Philip Thamaravelil
Ranch Hand

Joined: Feb 09, 2006
Posts: 99
mahesh matele wrote:
1) i want to add some validations to my website elements.

What scripting languages do i need

I have seen a few tutorials using javascript for validations and ajax 2!

Could it done using jsp 2 ?


You can certainly validate your form inputs via Javascript. Your approach would depend highly on your specific page design.

If your using forms, you can do something like:





Lots' of stuff on google for this..



Also, you can use tag libraries to verify.

Depends highly on your specific development paradigm.


Cheers,
Philip

mahesh matele
Greenhorn

Joined: Jan 23, 2012
Posts: 23
Hi,

Thanks for the reply.

So, i have used javascript for the validations ...and i guess i m done with it...will understand that in the testing phase.

So now i want to implement the logic.

I want to use jsp for that.

Which tool do you suggest......Eclipse or NetBeans ?

The tool i choose now is going to be used for the rest of my development cycle.So i need to choose it wisely.

Next i found a good tutorial here http://netbeans.org/kb/docs/web/mysql-webapp.html for website with NetBeans

Is there a similar site for Eclipse

Please suggest !



Also i m getting the below error:


Why i m getting this error ??

I have my mysql running.
Also the table is defined.
Philip Thamaravelil
Ranch Hand

Joined: Feb 09, 2006
Posts: 99
mahesh matele wrote:
Which tool do you suggest......Eclipse or NetBeans ?


Personally, I'd go for Eclipse.


mahesh matele wrote:

Why i m getting this error ??


From what you've posted, looks like there is an issue with your function. bml.Member_Type.

Have you tried executing it in your MySQL client?

Can you post your JSP code? Also, your output from tomcat with the full stack trace? Should help with figuring out the issue.


Cheers,
Philip
mahesh matele
Greenhorn

Joined: Jan 23, 2012
Posts: 23
This is my HTML page ...i m calling Insert_Data.jsp in my action on the form



This is my Insert_Data.jsp



And yes i could make out that the error was in my Member_Type .But even when i removed that element from jsp page it still gave me an error for the last value.

And the error line is pointing to the :

updateQuery = pstatement.executeUpdate();

I searched a lot for that error...a few sites said that i don't have privileges to insert into table.
So if thats the case i don't know how to grant privileges...and i m logging in as root and my password is abc123 .So i think i have global privileges.

Would appreciate some help here!!!i have no clue why is this error !!!
Philip Thamaravelil
Ranch Hand

Joined: Feb 09, 2006
Posts: 99
mahesh matele wrote:



Looks like your sql syntax has a few errors..I moved your ")"
Should look like:





As a best practice, this type of code is done in enterprise components... For example, a servlet.

Your creating a connection directly in the JSP page. If you had 100 simultaneous visitors to the page, that would mean 100 simultaneous connections to the database. I suggest google'ing "Tomcat Connection Pooling Tutorial".. this will give some insight into reusing database connections and allowing tomcat to manage them.

But, again I don't know the context. If your only doing a proof-of-concept it may or may-not be worth the time. But non-the-less, it's good to understand connection management.

Just because you are root in mysql, doesn't necessarily mean you have insert privledges into the database. Check your users permissions on "that" database with the MYSQL administrator tool.

Also, you should be using "executeQuery" instead of "executeUpdate". An insert doesn't return a result set.

Cheers,
Philip


mahesh matele
Greenhorn

Joined: Jan 23, 2012
Posts: 23
Hi,

That was a silly mistake..But i m afraid to say that it has not solved the error. []




i have :

1) stopped the tomcat server
2) made the changes
3) deleted the old war file and folder from the location (webapps)
4) Exported the changed war file to the webapps folder
5) started the tomcat server
6) New folder was created with name of war file
7) checked if changes worked on browser

But i m still getting the above error.
Philip Thamaravelil
Ranch Hand

Joined: Feb 09, 2006
Posts: 99
You don't have a database selected in your connection url.


mahesh matele
Greenhorn

Joined: Jan 23, 2012
Posts: 23
Hi,

ya correct

Just got it solved .

And it working smooth

Thanks for your help !!

Can jsp be debugged in eclipse ?

And also i would like to know if this is the correct way to deploy changes ?

1) stopped the tomcat server
2) made the changes
3) deleted the old war file and folder from the location (webapps)
4) Exported the changed war file to the webapps folder
5) started the tomcat server
6) New folder was created with name of war file
7) checked if changes worked on browser
Philip Thamaravelil
Ranch Hand

Joined: Feb 09, 2006
Posts: 99
Eclipse does have JSP debugging support. It won't catch run-time errors (as in the case with your database url) though, only compile-time.

No, to update your code in tomcat, you only need to create a new war and copy it to your webapps directory. Tomcat will pick up the change and deploy the new war.

Google "Deploy war with ANT"..and you will be very glad to setup ANT. save you LOTS of time.

Cheers,
Philip
mahesh matele
Greenhorn

Joined: Jan 23, 2012
Posts: 23
hi,

Thanks for your help !

I will follow what you have just said.

Will get back to you if i come across any other unsolvable errors !
mahesh matele
Greenhorn

Joined: Jan 23, 2012
Posts: 23
Hi Philip,

Back with a small query.

i would like to know - i want to generate a unique number for a column in my database.
Now having 2 options - 1) generate it in front end
2) create a trigger and call a function to generate unique number every time a row is inserted.
Which one is more appropriate and why ?

Can you help me with this ?
Philip Thamaravelil
Ranch Hand

Joined: Feb 09, 2006
Posts: 99
You need to create an "Identity Column".. Let the database handle the increment for you.

You want your insert to be an atomic operation.

Cheers,
Philip
mahesh matele
Greenhorn

Joined: Jan 23, 2012
Posts: 23
Thanks for the reply...

OK....I had created an identity column in my DB ...but i was thinking i would make a combination of randomly generated alphanumeric letters.

Thanks.
mahesh matele
Greenhorn

Joined: Jan 23, 2012
Posts: 23
Hi Philip,

One more query,

I m going to add a email functionality to the website.
I would like to know what are the requirements for that,

All i want to do is send a welcome email to the registered user..

Is there anything that is required..like a mail server ....or can i just send an email on some event ?

Please reply asap!
Thank you.
mahesh matele
Greenhorn

Joined: Jan 23, 2012
Posts: 23
Hi,

just to add to the above topic..

i have downloaded the javamail.api ....but i do not know where to keep it ? in java folder ? in tomcat folder ?

i may also have to add it to the classpath ?

Please tell me if there is anything else that is required....and also the location of where i can keep the above said javamail 1.4.4 folder

My java is in C:\Program Files\Java\jdk1.7.0_01 i.e JAVA_HOME

Please help!
mahesh matele
Greenhorn

Joined: Jan 23, 2012
Posts: 23
Hi,

Adding to the above mail :

1)I have put the JAVAMAIL 1.4.4 folder in C:/ProgramFiles/JAVA folder and updated the path for the .jar files in classpath.
2)As i m developing in ECLIPSE i have also right clicked on project folder -->Properties-->Java Build Path -->Libraries Tab --> and added my mail.jar there through add external jars.

So now when i pasted the below code i did not see any red underlinings.
The code is :



When executing this i get the below error :



Why i m getting this error ?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: creating website basic question
 
Similar Threads
question related to Practical Android Projects book
Importance of Certification in Landing a Job
How to Build a Simple JavaServer Faces Application
Creating a JSP site remotely
Chat Room