• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 274
  • Last Modified:

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.

J

0
jaggernat
Asked:
jaggernat
  • 6
  • 5
1 Solution
 
TrekkyLeaperCommented:
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.
0
 
jaggernatAuthor Commented:
r u sure its <%=2+2%> .....i am getting HTTP Status 500 error now

0
 
jaggernatAuthor Commented:
this is my jsp file:

<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<html>
<head><title>JSP Page</title></head>
<body>
Hello world!
<p/>
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" /> --%>

</body>
</html>
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
TrekkyLeaperCommented:
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:

http://www.apl.jhu.edu/%7Ehall/java/Servlet-Tutorial/

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

when i typed this example

<HTML>
<BODY>
<%
    // 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 %>
</BODY>
</HTML>


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

0
 
TrekkyLeaperCommented:
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" );
0
 
jaggernatAuthor Commented:
i c ,
i am using netbeans3.6 ..where is servers console in netbeans .

thanks
0
 
TrekkyLeaperCommented:
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.
0
 
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.

0
 
jaggernatAuthor Commented:
i give you the points since you took the time to get back to me :)
0
 
TrekkyLeaperCommented:
That's interesting. Could you post a link to that info so I can look into it?
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 6
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now