Win a copy of Securing DevOps this week in the Security forum!

sandy gupta

Ranch Hand
+ Follow
since Jan 30, 2001
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by sandy gupta

It does survive and it is a dash character. It shows up well on the windows 1252 encoding which your browser sets. But try changing the encoding on the browser to utf 8 and you will realize what i am talking bout.

BTW, I realized that the culprit was my java application which is using the US-ASCII charset on the unix box. I have tried everything from using readers instead of streams to using the string api to change the charset encoding but it seems like nothing is working.

If anyone has any idea of how you can force stuff in java to follow a particular encoding, please do let me know.
12 years ago
I have tried doing that and it does not help
12 years ago
I am having this really weird issue on Unix where some of the characters coming from Windows CMS (where else) are showing up as a ?
These characters are not normal in the sense that i can see that the bytecode assigned to these is really messed up.
Has anyone faced this issue earlier. If so, how do you go about solving this issue.

Here are the details.
I am using
h=(HttpURLConnection)webserver.openConnection();
h.connect();
//Get the input stream
in=h.getInputStream();

To get the input stream from a web file and then downloading it as an html file on the stream translates the weird character into a ?

Byte:83-->Char:S-->HexCode:3
Byte:121-->Char:y-->HexCode:9
Byte:110-->Char:n-->HexCode:E
Byte:100-->Char -->HexCode:4
Byte:114-->Char:r-->HexCode:2
Byte:111-->Char -->HexCode:F
Byte:109-->Char:m-->HexCode
Byte:101-->Char:e-->HexCode:5
Byte:32-->Char: -->HexCode:0
Byte:-106-->Char:?-->HexCode:6
Byte:32-->Char: -->HexCode:0
Byte:70-->Char:F-->HexCode:6
Byte:114-->Char:r-->HexCode:2
Byte:111-->Char -->HexCode:F
Byte:109-->Char:m-->HexCode
Byte:32-->Char: -->HexCode:0

Notice the byte value of -106 on that character. I have tried using readers setting the charset encoding to iso-8859-1 as well as utf8 but both gave the same results.

I am currently running out of options so please help.

Thanks
12 years ago
Hi

I am trying to pass multiple values through a hidden variable on a form post but am not getting the values in my form bean. What am i doing wrong?

jsp:

<html:hidden property="svalues" value="abc, def"/>

bean:

private String []svalues = null;

public String []getSvalues(){
return svalues;
}

public void setSvalues(String []values){
svalues = values;
}

TIA
S
13 years ago
I am about to start a project which requires a load of configuration information to be loaded on startup. I was thinking of using a Plug-In to load the information into these classes by parsing the xml configuration file. Much like what struts does in the framework for the struts-config.xml
What do the experts feel? Does anyone have any experience with this kinda set up? Are there any pitfalls/advantages to it? Any input is appreciated.

13 years ago
A neat way of doing this using struts is to submit the action to an intermediate servlet(action class) where all you do is to populate the second list based on the value of the first and then return to the original page. If you keep the action bean scope=session, then rest of the session information is mainatained and struts will auto-populate the values in all the other fields on the page. I have done this and it works. This is strictly to avoid scripting in client browsers which is a definate no-no for my project.
13 years ago
I am using sourceforges WebTestCase, from the jwebunit package. Now my problem is that when i try to run the tests(compiling is fine), i get a very weird error.
java.lang.reflect.InvocationTargetException
at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
at com.meterware.httpunit.parsing.NekoHTMLParser.parse(NekoHTMLParser.ja
va:41)
at com.meterware.httpunit.HTMLPage.parse(HTMLPage.java:244)
at com.meterware.httpunit.WebResponse.getReceivedPage(WebResponse.java:1
014)
at com.meterware.httpunit.WebResponse$Scriptable.load(WebResponse.java:6
11)
at com.meterware.httpunit.javascript.JavaScript$Window.initialize(JavaSc
ript.java:424)
at com.meterware.httpunit.javascript.JavaScript.run(JavaScript.java:80)
at com.meterware.httpunit.javascript.JavaScriptEngineFactory.associate(J
avaScriptEngineFactory.java:46)
at com.meterware.httpunit.FrameHolder.<init>(FrameHolder.java:44)
at com.meterware.httpunit.WebWindow.<init>(WebWindow.java:218)
at com.meterware.httpunit.WebClient.<init>(WebClient.java:50)
at com.meterware.httpunit.WebConversation.<init>(WebConversation.java:46
)
at net.sourceforge.jwebunit.TestContext.getWebClient(TestContext.java:26
0)
at net.sourceforge.jwebunit.HttpUnitDialog.initWebClient(HttpUnitDialog.
java:55)
at net.sourceforge.jwebunit.HttpUnitDialog.<init>(HttpUnitDialog.java:46
)
at net.sourceforge.jwebunit.WebTester.beginAt(WebTester.java:55)
at net.sourceforge.jwebunit.WebTestCase.beginAt(WebTestCase.java:46)
at com.mws.tests.TestSendMessageJsp.testUnSuccessfulMessage3(TestS
endMessageJsp.java:79)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at junit.swingui.TestRunner$16.run(TestRunner.java:623)

This exception is being thrown for all my test cases. I am not able to figure out why this is happening. I have all the classes that are needed in the classpath. It does not seem like a classpath issue to me. Yet.
Please let me know if this is a known issue or if someone has resolved this problem in the past. Looking fwd to a response from your side.
S
13 years ago
Your application resources properties file needs to be defined in your struts-config.xml. Did you do that.
<message-resources
parameter="com.XXX.registration.ApplicationResources"/>
14 years ago
Make an action that gets the data from wherever and then populates the formbean with the data and then send to the jsp page that you are trying to load and when the jsp loads, the formbean data can be loaded.
Lemme know if its still confusing
14 years ago
Shouldnt your struts-config.xml and web.xml be in the web-inf dir
14 years ago
What is it that we are doing here exactly? Can you be more detailed about it.
14 years ago
u could use jstl like this
<c:set var="speclist" value="${applicationScope.profileCache.professionSpecialtyListMap}"/>
<c:forEach var="entry" items="${speclist}">
<c:if test='${entry.key == prof}'>
<select name="specialty" class="text10">
<option value="">---------- Select One ----------</option>
<c:forEach var="specialty" items="${entry.value}">
<c:set var="specid" value="${specialty.specialtyID}"/>
<c:set var="name" value="${specialty.description}"/>
<option value="<c ut value="${specid}"/>" <c:if test='${specid == spec}'> selected </c:if> ><c ut value="${name}"/></option>
</c:forEach>
</select>
</c:if>
</c:forEach>
and java script should be fine but why would it cause the form to submit unless u are using an html:img tag........i had a problem when i was using html:img buttons initially coz i was accidentally calling the form on the click of the image.............make sure that its not the same thing....
14 years ago
Hey Sumit,
This is absolutely possible. You have to understand that the dynavalidatorform is a form bean which is used to store the information being transferred betn server and client and the action is the controller which controls the application flow so there is no reason that one can not be mixed with the other.
DispatchAction is an action class that uses method names for choosing which method to execute (selective execution) but the validation fwk uses the path specified in the struts-config.xml to validate irrespective of the action class and the method name used.
So you should definately be able to use it.
Let me know if you have problems doing this.
Sahil
14 years ago
if your jsp1 uses the same form bean as jsp2 and your scope of the bean is set to session, then you should see this automatically. if this is not true, then you have to set the jsp2's form bean with the value from the jsp1's form bean in your action to which jsp1 posts explicitly before sending to the jsp2.
Sahil
14 years ago
Simple solution
Make a class and put this in your web.xml
<servlet>
<servlet-name>myservlet</servlet-name>
<servlet-class>mypackage.MyClass</servlet-class>
<init-param>
<param-name>myds</param-name>
<param-value>jdbc/MyDS</param-value>
</init-param>
<load-on-startup>10</load-on-startup>
</servlet>
Note the load-on-startup tag which tells the server, the priority loading order of this servlet. In the init of this class, you can load your objects and store them in some context avl to all applications (appcontext).
I have this set up on both wl8 and tomcat4.1
Sahil
14 years ago