jsp beginner

hi ,,i am new to jsp and have question about jsp setup in NetBeans3.6
i was working on servlets all these days and now decided to move ahead with jsp's

1) can i use the same mounted directory as i used for servlets
2)Do i need to create a web module for this mounted directory as i did for servlets.

Infact i did the above two steps and put my first jsp program helloworld.jsp in c:\winnt\profiles\jay\desktop\jsp ( which is my mounted directory)

when i save and execute the file  only html is getting displayed. For instance

the statement
" HelloWorld  2+2 is $(2+2) "

is getting displayed as   " HelloWorld  2+2 is $(2+2) "  instead of "HelloWorld 2+2 is 4 "

any help appreciated.


LVL 10
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I don't exactly remember how 3.6 works the web apps. You should be able to create your JSP wherever the "Document Base" folder in the web module points. You can use the same one as you did for your sevlets if you want. As for your example, $(2+2) will not do anything in JSP. It needs to be <%=2+2%>, I think.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jaggernatAuthor Commented:
r u sure its <%=2+2%> .....i am getting HTTP Status 500 error now

jaggernatAuthor Commented:
this is my jsp file:

<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<head><title>JSP Page</title></head>
Hello world!
2+2 is $(2+2) and 4*4 is $(4*4)
<%-- <jsp:useBean id="beanInstanceName" scope="session" class="beanPackage.BeanClassName" /> --%>
<%-- <jsp:getProperty name="beanInstanceName"  property="propertyName" /> --%>

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

I'm pretty sure. Here is the JSP section of a tutorial that talks about how to do script segments (regular Java code) inside JSPs:


It seems like a pretty comprehensive page.
jaggernatAuthor Commented:
ok looks like i am getting closer

when i typed this example

    // This is a scriptlet.  Notice that the "date"
    // variable we declare here is available in the
    // embedded expression later on.
    System.out.println( "Evaluating date now" );
    java.util.Date date = new java.util.Date();
Hello!  The time is now <%= date %>

when above program is executed , i cannot  see the "Evaluating date now"  , although i can see the Hello ! the time is now
Nov10 18.22

System.out.println() is going to print to the server's console, not to the page. You need to get the output stream for the JSP which is called "out". So instead of:

System.out.println( "Evaluating date now" );

you need:

out.println( "Evaluating date now" );
jaggernatAuthor Commented:
i c ,
i am using netbeans3.6 ..where is servers console in netbeans .

Unfortunately, I don't have netbeans 3.6 installed anywhere at the moment. In 4.1, though, I get an output window when I start the server. If you get an output screen, then that's where the System.out.println() calls will go.

Just to clarify what I said earlier (because I wasn't very clear), out.println() will output to the page and System.out.println() will write to the console.
jaggernatAuthor Commented:
i figured out there is something called Expression Language that jsp2.0 supports. you can use the $ sign in expression language to perform mathematical computations.

jaggernatAuthor Commented:
i give you the points since you took the time to get back to me :)
That's interesting. Could you post a link to that info so I can look into it?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.