Please helpppppp me on base64 Codec - jakarta

J

jsp beginner

Hi guys

I am a beginner on JSP. I have a script to decode a string but it
generates an error.

This is what I did.

1. Download "commons-codec-1.3" from the Jakara web site. -
http://jakarta.apache.org/commons/codec/

2. And put it onto this directory - C:\Tomcat4\commons-codec-1.3
3. Set up the jar file in classpath like -
C:\Tomcat4\commons-codec-1.3\commons-codec-1.3.jar;
4. Rebooth my machine.
5. Run my jsp script below.
6. Apache error.
* My tomcat set up is working fine. All my jsp files work fine but I
guess I am doing wrong with this following script and the set-up with
the CODEC.

Please help me what I am doing wrong. Do I add "import" in the first
tag next contentType property? If so, what should it be?

<%@ page contentType="text/html;" import="what?" %>


This is the jsp file.

<base64.jsp>

<%@ page contentType="text/html;" %>


<%

String hi = "hello";
byte[] encodedBytes = Base64.encodeBase64(hi.getBytes());
String decodedString = new String(Base64.decodeBase64(encodedBytes));

%>

show me <%=decodeString%>
 
R

Robert kebernet Cooper

jsp said:
Hi guys

I am a beginner on JSP. I have a script to decode a string but it
generates an error.

This is what I did.

1. Download "commons-codec-1.3" from the Jakara web site. -
http://jakarta.apache.org/commons/codec/

2. And put it onto this directory - C:\Tomcat4\commons-codec-1.3
3. Set up the jar file in classpath like -
C:\Tomcat4\commons-codec-1.3\commons-codec-1.3.jar;

You should really just drop the jar file in the WEB-INF/lib directory
for your application.
4. Rebooth my machine.

You never have to do that with Java stuff :p
5. Run my jsp script below.
6. Apache error.
* My tomcat set up is working fine. All my jsp files work fine but I
guess I am doing wrong with this following script and the set-up with
the CODEC.

Please help me what I am doing wrong. Do I add "import" in the first
tag next contentType property? If so, what should it be?

<%@ page contentType="text/html;" import="what?" %>

Look at the docs for the Base64 encoder. Its probably something like
org.apache.commons.codec.Base64, assuming the rest of your code is
correct
 
H

humm

Thank you so much for your help.
Here are the structures of my tomcat directories.


C:\Tomcat4\webapps\examples\WEB-INF
C:\Tomcat4\webapps\examples\jsp
C:\Tomcat4\webapps\examples\jsp\test
C:\Tomcat4\webapps\examples\WEB-INF\classes
C:\Tomcat4\webapps\examples\WEB-INF\jsp
C:\Tomcat4\webapps\ROOT\WEB-INF
C:\Tomcat4\webapps\ROOT\WEB-INF\web.xml


I have a lot of jsp files in C:\Tomcat4\webapps\examples\jsp\test
They all work fine so I would like to add the base64.jsp into the
folder. Please let me know which WEB-INF/lib I should put in the jar
file and is there any other things I need to configure to make it work?
maybe modifying web.xml file or something?

And, you didn't mention about <%@ page contentType="text/html;"
import="what?" %>. I guess I don't need to change any code in my script
then, rigth?

Please please help!
 
R

Robert kebernet Cooper

Ok. You need to think about things in terms of "Context". Generally
each "top directory" in your server is a context, though the "ROOT"
context is a special case-- many times its better to just pretend it
doesn't exist. Since you are putting stuff in eamples/jsp/ that means
you are in the "examples" context and want to put your files in the
examples/WEB-INF directory.

In the world of J2EE, each context exists as a separate application,
with its own Session information, "Application/Context" information,
and classpath. Any jar files you put in a webapp's WEB-INF/lib file
will automagically appear in the classpath for anything you run from
there (jsp/servlet/etc), and the WEB-INF/classes contains class files
(with proper directory pathing) to be put in the class path.
 
H

humm

Thank you so much for your help.
Here are the structures of my tomcat directories.


C:\Tomcat4\webapps\examples\WEB-INF
C:\Tomcat4\webapps\examples\jsp
C:\Tomcat4\webapps\examples\jsp\test
C:\Tomcat4\webapps\examples\WEB-INF\classes
C:\Tomcat4\webapps\examples\WEB-INF\jsp
C:\Tomcat4\webapps\ROOT\WEB-INF
C:\Tomcat4\webapps\ROOT\WEB-INF\web.xml


I have a lot of jsp files in C:\Tomcat4\webapps\examples\jsp\test
They all work fine so I would like to add the base64.jsp into the
folder. Please let me know which WEB-INF/lib I should put in the jar
file and is there any other things I need to configure to make it work?
maybe modifying web.xml file or something?

And, you didn't mention about <%@ page contentType="text/html;"
import="what?" %>. I guess I don't need to change any code in my script
then, rigth?

Please please help!
 
H

humm

Thank you so much for your help.
Here are the structures of my tomcat directories.


C:\Tomcat4\webapps\examples\WEB-INF
C:\Tomcat4\webapps\examples\jsp
C:\Tomcat4\webapps\examples\jsp\test
C:\Tomcat4\webapps\examples\WEB-INF\classes
C:\Tomcat4\webapps\examples\WEB-INF\jsp
C:\Tomcat4\webapps\ROOT\WEB-INF
C:\Tomcat4\webapps\ROOT\WEB-INF\web.xml


I have a lot of jsp files in C:\Tomcat4\webapps\examples\jsp\test
They all work fine so I would like to add the base64.jsp into the
folder. Please let me know which WEB-INF/lib I should put in the jar
file and is there any other things I need to configure to make it work?
maybe modifying web.xml file or something?

And, you didn't mention about <%@ page contentType="text/html;"
import="what?" %>. I guess I don't need to change any code in my script
then, rigth?

Please please help!
 
H

humm

Thank you so much for your help.
Here are the structures of my tomcat directories.


C:\Tomcat4\webapps\examples\WEB-INF
C:\Tomcat4\webapps\examples\jsp
C:\Tomcat4\webapps\examples\jsp\test
C:\Tomcat4\webapps\examples\WEB-INF\classes
C:\Tomcat4\webapps\examples\WEB-INF\jsp
C:\Tomcat4\webapps\ROOT\WEB-INF
C:\Tomcat4\webapps\ROOT\WEB-INF\web.xml


I have a lot of jsp files in C:\Tomcat4\webapps\examples\jsp\test
They all work fine so I would like to add the base64.jsp into the
folder. Please let me know which WEB-INF/lib I should put in the jar
file and is there any other things I need to configure to make it work?
maybe modifying web.xml file or something?

And, you didn't mention about <%@ page contentType="text/html;"
import="what?" %>. I guess I don't need to change any code in my script
then, rigth?

Please please help!
 
W

William Brogden

Hi guys

I am a beginner on JSP. I have a script to decode a string but it
generates an error.

This is what I did.

1. Download "commons-codec-1.3" from the Jakara web site. -
http://jakarta.apache.org/commons/codec/

2. And put it onto this directory - C:\Tomcat4\commons-codec-1.3
3. Set up the jar file in classpath like -
C:\Tomcat4\commons-codec-1.3\commons-codec-1.3.jar;

Tomcat totally ignores your CLASSPATH settings - see the
class-loader-howto.html file in your tomcat-docs for the various
places that Tomcat looks for library jar files.


Bill
 
T

Tris Orendorff

(e-mail address removed) (jsp beginner) wrote in
Hi guys

I am a beginner on JSP. I have a script to decode a string but it
generates an error.

This is the jsp file.

<base64.jsp>

<%@ page contentType="text/html;" %>


<%

String hi = "hello";
byte[] encodedBytes = Base64.encodeBase64(hi.getBytes());
String decodedString = new
String(Base64.decodeBase64(encodedBytes));

%>

show me <%=decodeString%>

Unless this is a typo getting your jsp file into this message, your last line should be:
show me <%=decodedString%>


--
Sincerely,

Tris Orendorff

-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GCS d++ s+:- a+ C+ UL++++ P+ L+ E- W+ N++ o- K++ w+ O+ M !V PS+ PE Y+ PGP t+ !5 X- R- tv--- b++
DI++ D+ G++ e++ h---- r+++ y+++
------END GEEK CODE BLOCK------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top