Win a copy of Kotlin in Action this week in the Kotlin forum!
    Bookmark Topic Watch Topic
  • New Topic

regarding scriptlets  RSS feed

 
shanu jain
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Report post to moderator
hi...
i am trying to develop a web client using jsp... am using Apache... i tried to run a sample jsp file... the content is as follows...

<HTML>
<BODY>
Hello! The time is now <%= new java.util.Date() %>
</BODY>
</HTML>

but even this simple file is not executing properly... the output displays only "Hello! The time is now " and not the date.. anything inside <% %> is not getting recognized... have similar problem with my other jsp files...

thanks in advance.. a quick reply would help a lot...
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66203
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Report post to moderator
Apache is not a JSP engine.
 
shanu jain
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Report post to moderator
k thanks.. but the same code din work even when i tried running with the tomcat server... any idea why?? i even set the path for my java files..
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66203
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Report post to moderator
If you've got Tomcat set up correctly it should work without difficulty. There is a Tomcat forum for Tomcat setup questions.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Report post to moderator
What is your file called ?
 
shanu jain
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Report post to moderator
hi..
its called sample.jsp
is there some limitation like a jsp file can be run only by an initial call from a html file??
and some limitation on where the jsp files need to be saved??
thanks a lot for all ur help!!
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66203
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Report post to moderator
Originally posted by shanu jain:

and some limitation on where the jsp files need to be saved??


Well of course your web app needs to be properly formed.

thanks a lot for all ur help!!


Please show your appreciation by dropping the use of abbreviations such as "ur" and spelling out the entire word. Thanks.
 
satishkumar janakiraman
Ranch Hand
Posts: 334
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi

Try this in tomcat



bye for now
sat
 
satishkumar janakiraman
Ranch Hand
Posts: 334
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi,

I forgot to add the following in your code. Change your code like this



bye for now
sat
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66203
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Report post to moderator
No, I suggest not doing that. Not only is using the <%! a dangerous habit to get into, it's immaterial to the problem. If the original JSP isn't working (what does that mean, by the way), the suggested JSP isn't going to either.
 
ak pillai
author
Ranch Hand
Posts: 288
  • Mark post as helpful
  • send pies
  • Report post to moderator


The above code should work.


The following code is not threadsafe and not recommended.




The Date variable "d" will become a member (aka instance) variable in the converted servlet. if you take the ! mark out, then it becomes a local variable.
 
shanu jain
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Report post to moderator
hi everybody..
thanks a lot for all YOUR help.. the problem was that i had set the JAVA_HOME variable to my j2sdk1.5.0_06.. guess tomcat does not support this.. after setting it to j2sdk1.4.2_03, the sample.jsp file ran without any problem.. could anybody help me with database connection(mysql) from a jsp file..?? is there any classpath that needs to be set?? any other pre-requisites needed?? tried setting the classpath to my mysql jar file, does not help..
got an error like the one stated below when i ran my jsp file..
java.lang.NoClassDefFoundError: org/aspectj/lang/Signature
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Report post to moderator
Its better to raise another thread in JDBC Forum.
 
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!