• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 00:53
CEST 06:53
KST 13:53
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
[ASL19] Finals Recap: Standing Tall9HomeStory Cup 27 - Info & Preview18Classic wins Code S Season 2 (2025)16Code S RO4 & Finals Preview: herO, Rogue, Classic, GuMiho0TL Team Map Contest #5: Presented by Monster Energy6
Community News
Flash Announces Hiatus From ASL54Weekly Cups (June 23-29): Reynor in world title form?12FEL Cracov 2025 (July 27) - $8000 live event16Esports World Cup 2025 - Final Player Roster16Weekly Cups (June 16-22): Clem strikes back1
StarCraft 2
General
The SCII GOAT: A statistical Evaluation The GOAT ranking of GOAT rankings Statistics for vetoed/disliked maps How does the number of casters affect your enjoyment of esports? Esports World Cup 2025 - Final Player Roster
Tourneys
Korean Starcraft League Week 77 Master Swan Open (Global Bronze-Master 2) RSL: Revival, a new crowdfunded tournament series [GSL 2025] Code S: Season 2 - Semi Finals & Finals $5,100+ SEL Season 2 Championship (SC: Evo)
Strategy
How did i lose this ZvP, whats the proper response Simple Questions Simple Answers
Custom Maps
[UMS] Zillion Zerglings
External Content
Mutation # 480 Moths to the Flame Mutation # 479 Worn Out Welcome Mutation # 478 Instant Karma Mutation # 477 Slow and Steady
Brood War
General
Player “Jedi” cheat on CSL Flash Announces Hiatus From ASL BGH Auto Balance -> http://bghmmr.eu/ Unit and Spell Similarities Help: rep cant save
Tourneys
[Megathread] Daily Proleagues [BSL20] Grand Finals - Sunday 20:00 CET Small VOD Thread 2.0 [BSL20] GosuLeague RO16 - Tue & Wed 20:00+CET
Strategy
Simple Questions, Simple Answers I am doing this better than progamers do.
Other Games
General Games
Stormgate/Frost Giant Megathread Nintendo Switch Thread Path of Exile What do you want from future RTS games? Beyond All Reason
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread Vanilla Mini Mafia
Community
General
US Politics Mega-thread Trading/Investing Thread Things Aren’t Peaceful in Palestine Russo-Ukrainian War Thread The Games Industry And ATVI
Fan Clubs
SKT1 Classic Fan Club! Maru Fan Club
Media & Entertainment
Anime Discussion Thread [Manga] One Piece [\m/] Heavy Metal Thread
Sports
Formula 1 Discussion 2024 - 2025 Football Thread NBA General Discussion TeamLiquid Health and Fitness Initiative For 2023 NHL Playoffs 2024
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
Blogs
Culture Clash in Video Games…
TrAiDoS
from making sc maps to makin…
Husyelt
Blog #2
tankgirl
StarCraft improvement
iopq
Trip to the Zoo
micronesia
Customize Sidebar...

Website Feedback

Closed Threads



Active: 664 users

The Big Programming Thread - Page 614

Forum Index > General Forum
Post a Reply
Prev 1 612 613 614 615 616 1031 Next
Thread Rules
1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution.
2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20)
3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible.
4. Use [code] tags to format code blocks.
WolfintheSheep
Profile Joined June 2011
Canada14127 Posts
April 15 2015 21:03 GMT
#12261
On April 15 2015 13:41 FFGenerations wrote:
ok well i've given up trying to make it work this way for now. i sort of understand what you've been saying earlier about the autogenerated thing being fucked up. what you wrote totally flew over my head before, but you kept railing on about it until i started to understand. thanks all, you've been brilliant!

will move on to trying to parse it myself instead

Good that you're moving in the right direction .

Just a couple things so you don't get overly dissuaded. There's nothing inherently wrong with using auto-generated code, and in fact a lot of major frameworks will have you relying a bit on them (C# with ADO.NET comes to mind). The important thing is to understand why you're using an auto-generator, and how actually interact with it.

Overriding ToString() methods is also a valid option in many cases, and returning the main identifier for an object like a Name is definitely a good time to do it. Of course, in this circumstance it would be a band-aid solution, because inevitably you'll want other information from you objects, and you'll be right back to the same problem you started with.

Finally, parsing text may seem like a massive undertaking at first, but it's something you will be dealing with eventually if you're a programmer of any kind, so it's definitely something worthwhile to learn. Luckily for you, you're dealing with XML, which is basically designed to be parsed easily.
Average means I'm better than half of you.
FFGenerations
Profile Blog Joined April 2011
7088 Posts
Last Edited: 2015-04-15 22:55:38
April 15 2015 22:33 GMT
#12262
i found a pretty crazy good tutorial



i done the basic one first which also shows it being done with Lists then was wondering why the fuck my nested xml wasnt working and then found the person had just uploaded this one, thank god

so ..... the next thing i'm going to find out is how "deep" into the xml file i need to go to get the data i want i guess, or how far i can simplify it before it fucks up on me. i tend to lean towards it being easy now but i might end up having to look at a plugin that jumps to the parts i want, or something, which would be annoying :D since i have 5 days left lol

the xml file starts off something like this

<ann>
- <anime id="16547" gid="1838091909" type="OAV" name="Kono Danshi, Sekika ni Nayandemasu" precision="OAV" generated-on="2015-04-14T20:49:39Z">
<related-prev rel="related to" id="13312" />
- <info gid="1527892938" type="Picture" src="http://cdn.animenewsnetwork.com/thumbnails/fit200x200/encyc/A16547-1527892938.1417492374.jpg" width="139" height="200">
<img src="http://cdn.animenewsnetwork.com/thumbnails/hotlink-fit200x200/encyc/A16547-1527892938.1417492374.jpg" width="139" height="200" />
<img src="http://cdn.animenewsnetwork.com/thumbnails/hotlink-max500x600/encyc/A16547-1527892938.1417492374.jpg" width="174" height="250" />
</info>
<info gid="2071101469" type="Main title" lang="EN">Kono Danshi, Sekika ni Nayandemasu</info>
<info gid="367748411" type="Alternative title" lang="JA">この男子、石化に悩んでます。</info>
<info gid="742528363" type="Genres">supernatural</info>
<info gid="3133430704" type="Themes">yaoi</info>
<info gid="1492846673" type="Running time">26</info>


so thats like

<ann>
<anime> (use @XmlValue here maybe to grab 'anime id' and 'anime name'? need to check what it does exactly)
<info></info>
<info></info> (how to deal with multiple infos? maybe @XmlValue will straight up work here too to grab 'info src'. or maybe the parser will return a List of infos in this case)
.....
</anime
</ann>
Cool BW Music Vid - youtube.com/watch?v=W54nlqJ-Nx8 ~~~~~ ᕤ OYSTERS ᕤ CLAMS ᕤ AND ᕤ CUCKOLDS ᕤ ~~~~~~ ༼ ᕤ◕◡◕ ༽ᕤ PUNCH HIM ༼ ᕤ◕◡◕ ༽ᕤ
FFGenerations
Profile Blog Joined April 2011
7088 Posts
Last Edited: 2015-04-16 01:49:40
April 16 2015 01:32 GMT
#12263
hi, im a bit stuck on this bit

so from what i can gather Ann (top class) returns as a list of Anime objects

the Anime class should have multiple attributes though: name, id and List of Info objects

FIXED
+ Show Spoiler +

so right now i have it looking like this:

public class Anime {

private String id;
private String name;
private List<Info> infolist;
...
public List<Info> getInfolist() {
return infolist;
}

public void setInfolist(List<Info> infolist) {
this.infolist = infolist;
}
...
public Anime(String id, String name, List<Info> infolist) {
this.infolist = infolist;
this.id = id;
this.name = name;
}


this looks different to the Ann class where i have

public class Ann {

private List<Anime> Ann = new ArrayList<Anime>();

@XmlElement(name="anime")
public List<Anime> getAnn() {
return Ann;
}

public void setAnn(List<Anime> Ann) {
this.Ann = Ann;
}


after unmarshalling the xml file into Ann, i am able to perform

for (Anime anime : ann.getAnn()) {

System.out.println("ID: " + anime.getId());
System.out.println("Name: " + anime.getName());

this works.

however i am struggling to be able to access the Info list that should be in the anime class.

i guess the question is, how do i correctly set a list of Info as an attribute of the anime class

Anime class did look similar to Ann to begin with, as below, but i thought maybe that was wrong


public class Anime {

private String id;
private String name;
private List<Info> Anime = new ArrayList<Info>();
...
public Anime(String id, String name) {
this.id = id;
this.name = name;
}



i reverted the code back to how it was in the tutorial (where the topmost class had only 1 attribute so i thought it might look different).

then in my unmarshaller i added a 2nd for loop to try to access the Info list , somehow i got the right syntax


for (Anime anime : ann.getAnn()) {

System.out.println("ID: " + anime.getId());
System.out.println("Name: " + anime.getName());

for (Info temp : anime.getAnime()){
System.out.println("Info: "+temp.getSrc());
}
}
Cool BW Music Vid - youtube.com/watch?v=W54nlqJ-Nx8 ~~~~~ ᕤ OYSTERS ᕤ CLAMS ᕤ AND ᕤ CUCKOLDS ᕤ ~~~~~~ ༼ ᕤ◕◡◕ ༽ᕤ PUNCH HIM ༼ ᕤ◕◡◕ ༽ᕤ
Blitzkrieg0
Profile Blog Joined August 2010
United States13132 Posts
Last Edited: 2015-04-16 01:53:34
April 16 2015 01:47 GMT
#12264
+ Show Spoiler [you fixed it] +
private List<Info> Anime = new ArrayList<Info>();

Why is the name of the variable Anime? Do you even need this field? Each Anime having a list of "Info" (whatever that means) seems pretty stupid in the first place. If you need more fields you can create them and call them things that actually make sense. You'd want to add fields for say release date or author rather than creating a list of Info.


I really dislike the idea of this Info class, but if it works then I won't rain on your parade.
I'll always be your shadow and veil your eyes from states of ain soph aur.
FFGenerations
Profile Blog Joined April 2011
7088 Posts
Last Edited: 2015-04-16 01:59:28
April 16 2015 01:53 GMT
#12265
i'm using Info because its one of the XML tags... it occurs dozens of times for each anime entry with just random different info in:

- <info gid="1527892938" type="Picture" src="http://cdn.animenewsnetwork.com/thumbnails/fit200x200/encyc/A16547-1527892938.1417492374.jpg" width="139" height="200">
<img src="http://cdn.animenewsnetwork.com/thumbnails/hotlink-fit200x200/encyc/A16547-1527892938.1417492374.jpg" width="139" height="200" />
<img src="http://cdn.animenewsnetwork.com/thumbnails/hotlink-max500x600/encyc/A16547-1527892938.1417492374.jpg" width="174" height="250" />
</info>
<info gid="2071101469" type="Main title" lang="EN">Kono Danshi, Sekika ni Nayandemasu</info>
<info gid="367748411" type="Alternative title" lang="JA">この男子、石化に悩んでます。</info>
<info gid="742528363" type="Genres">supernatural</info>
<info gid="3133430704" type="Themes">yaoi</info>
etc


so i'm currently saving everything in an info tag into an Info object


@XmlRootElement (name="info")
public class Info {

private String src;

@XmlAttribute(name="src")
public String getSrc() {
return src;
}


and taking the @XmlAttribute from each info entry (if it exists) (only 1 exists per anime and i only need the 1, so that's handy) and accessing it with info.getSrc

right now i'm getting....

[image loading]

which is basically "HOLY FUCK I DONE IT AND SO FAST LOL OMFG TNX TUTORIAL also tnx brain and planning on paper lol"

btw is it normal for netbeans to ramp up to 1,300,000 memory lol

look lol

[image loading]
Cool BW Music Vid - youtube.com/watch?v=W54nlqJ-Nx8 ~~~~~ ᕤ OYSTERS ᕤ CLAMS ᕤ AND ᕤ CUCKOLDS ᕤ ~~~~~~ ༼ ᕤ◕◡◕ ༽ᕤ PUNCH HIM ༼ ᕤ◕◡◕ ༽ᕤ
Blitzkrieg0
Profile Blog Joined August 2010
United States13132 Posts
Last Edited: 2015-04-16 02:05:16
April 16 2015 01:58 GMT
#12266
On April 16 2015 10:53 FFGenerations wrote:
btw is it normal for netbeans to ramp up to 1,300,000 memory lol


Well each of those Info objects is at least 20 bytes and then you have a ton of them per parse so...

catch (Exception e)


My eyes are bleeding. I guess if you're just going to print the message then maybe it doesn't matter, but ^_^
I'll always be your shadow and veil your eyes from states of ain soph aur.
FFGenerations
Profile Blog Joined April 2011
7088 Posts
Last Edited: 2015-04-16 02:36:54
April 16 2015 02:05 GMT
#12267
what i would delete that shit but it probably goes all red

i'm going to use the data to populate a webpage frontend for the user and also save it to a local database or do something else with it

i guess my next task is to go figure out the API get request so it doesn't look like a complete hackjob




i have a sort of interesting question .... how would i describe what this is doing in non-retard terms? for example i am trying to describe it like:

"custom parser that unmarshalls desired data from my sample nested xml file into objects with inheritance " <- this last bit, how should it be described? i want to indicate that the classes are connected and also use Lists as attributes.....

silly question but maybe you wanna answer it . i'm really bad at using terminology . i guess i could phrase it "custom parser that unmarshalls desired data from my sample nexted xml file into objects using inheritance and lists as attributes"
Cool BW Music Vid - youtube.com/watch?v=W54nlqJ-Nx8 ~~~~~ ᕤ OYSTERS ᕤ CLAMS ᕤ AND ᕤ CUCKOLDS ᕤ ~~~~~~ ༼ ᕤ◕◡◕ ༽ᕤ PUNCH HIM ༼ ᕤ◕◡◕ ༽ᕤ
WolfintheSheep
Profile Joined June 2011
Canada14127 Posts
April 16 2015 02:47 GMT
#12268
I'm pretty bad at jargon too, so can't really help you there . It's basically a practice thing.

Also, you seem to over-complicating things by having an Info class. If the data is stored like this:
<anime id="16547" gid="1838091909" type="OAV" name="Kono Danshi, Sekika ni Nayandemasu" precision="OAV" generated-on="2015-04-14T20:49:39Z">
<info gid="2071101469" type="Main title" lang="EN">Kono Danshi, Sekika ni Nayandemasu</info>
<info gid="367748411" type="Alternative title" lang="JA">この男子、石化に悩んでます。</info>
<info gid="742528363" type="Genres">supernatural</info>
<info gid="3133430704" type="Themes">yaoi</info>
<info gid="1492846673" type="Running time">26</info>
</anime>


Then you should be parsing the type field in the info tags, and then pass the value into a variable in the Anime class. Basically, your class should look something like this:
class Anime{
private string title;
private string altTitle;
private string genre;
private List<string> themes; //assuming >1 theme is possible, otherwise just a single string
private double runTime;
}
Average means I'm better than half of you.
phar
Profile Joined August 2011
United States1080 Posts
April 16 2015 03:05 GMT
#12269
^^ strongly agree with using separate fields for things instead of just generic repeated info

You can heave a repeated info for unknown info tags if you want, but try to get more stuff parsed in up front, it's more useful.
Who after all is today speaking about the destruction of the Armenians?
Blitzkrieg0
Profile Blog Joined August 2010
United States13132 Posts
Last Edited: 2015-04-16 03:07:43
April 16 2015 03:06 GMT
#12270
On April 16 2015 11:05 FFGenerations wrote:

"custom parser that unmarshalls desired data from my sample nested xml file into objects with inheritance " <- this last bit, how should it be described? i want to indicate that the classes are connected and also use Lists as attributes.....

silly question but maybe you wanna answer it . i'm really bad at using terminology . i guess i could phrase it "custom parser that unmarshalls desired data from my sample nexted xml file into objects using inheritance and lists as attributes"


Well you didn't actually end up using inheritance so that would just be a lie. We thought you needed inheritance because you had Anime and Manga classes before, but the Manga class disappeared so you don't need/aren't using inheritance.

The application services client anime requests by acquiring the information from <webservice> and displaying them in a user friendly manner. How this works under the hood is irrelevant unless that is what you're supposed to be describing.
I'll always be your shadow and veil your eyes from states of ain soph aur.
FFGenerations
Profile Blog Joined April 2011
7088 Posts
Last Edited: 2015-04-16 03:21:46
April 16 2015 03:19 GMT
#12271
i'm not sure if that is possible

the way i am doing it is

look at @XmlRootElement (name="info")
look at @XmlAttribute(name="src")
save this


if there is an xml parser functionality that lets me check for Picture inside Infos then take the corresponding SRC from that Info and put it straight into Anime then sure....but i don't know if @XmlAttribute or @Something exists to do that

if anything there might be a plugin that lets you do that, like it autoscans the document and returns X for your nomatter where X is located...........

there is no fucking way i'm getting into that though :D i've got 4 days to finish this and then 4 days to do 2 other major assignments . edit: unless there is @functionality that just does that.............
Cool BW Music Vid - youtube.com/watch?v=W54nlqJ-Nx8 ~~~~~ ᕤ OYSTERS ᕤ CLAMS ᕤ AND ᕤ CUCKOLDS ᕤ ~~~~~~ ༼ ᕤ◕◡◕ ༽ᕤ PUNCH HIM ༼ ᕤ◕◡◕ ༽ᕤ
FFGenerations
Profile Blog Joined April 2011
7088 Posts
April 16 2015 03:23 GMT
#12272
On April 16 2015 12:06 Blitzkrieg0 wrote:
Show nested quote +
On April 16 2015 11:05 FFGenerations wrote:

"custom parser that unmarshalls desired data from my sample nested xml file into objects with inheritance " <- this last bit, how should it be described? i want to indicate that the classes are connected and also use Lists as attributes.....

silly question but maybe you wanna answer it . i'm really bad at using terminology . i guess i could phrase it "custom parser that unmarshalls desired data from my sample nexted xml file into objects using inheritance and lists as attributes"


Well you didn't actually end up using inheritance so that would just be a lie. We thought you needed inheritance because you had Anime and Manga classes before, but the Manga class disappeared so you don't need/aren't using inheritance.

The application services client anime requests by acquiring the information from <webservice> and displaying them in a user friendly manner. How this works under the hood is irrelevant unless that is what you're supposed to be describing.


i was just describing the "prototype version" for when i have to write about it and sound mildly technical or whatever
Cool BW Music Vid - youtube.com/watch?v=W54nlqJ-Nx8 ~~~~~ ᕤ OYSTERS ᕤ CLAMS ᕤ AND ᕤ CUCKOLDS ᕤ ~~~~~~ ༼ ᕤ◕◡◕ ༽ᕤ PUNCH HIM ༼ ᕤ◕◡◕ ༽ᕤ
WolfintheSheep
Profile Joined June 2011
Canada14127 Posts
April 16 2015 03:29 GMT
#12273
Well, can't help you with the specifics because I haven't used JAXB before. That said, this is the part where you learn that your power to Google is what makes you a programmer :D.
Average means I'm better than half of you.
ArchmageKruzer
Profile Joined August 2013
64 Posts
April 16 2015 03:43 GMT
#12274
So a couple of my friends and I want to make an IOS game. Currently we're writing the code in Java and then we're gonna import it into IOS. My question is is this a good idea, and if so, do you have any tricks and stuff to make the import easier, since there are probably gonna be like a million things going wrong once we do it.
Also, i've been poking around for engines, and 5 mins of google got me to the Unreal engine, which seems pretty OK. Any engine suggestions for IOS games, and tips/tutorials on how to use them?
FFGenerations
Profile Blog Joined April 2011
7088 Posts
Last Edited: 2015-04-16 13:17:07
April 16 2015 04:30 GMT
#12275
+ Show Spoiler +
(ignore this bit)
+ Show Spoiler +
so apparently you don't need to use REST web services, you can just have

URL url = new URL( "http://cdn.animenewsnetwork.com/encyclopedia/api.xml?title=~neon genesis" );

Ann ann = (Ann) ums.unmarshal(url);

and it does the get request and puts it straight into your parser. wtf. that is insane
i just shaved like 40 years off my life


i think i move on to figuring out how to make it into MVC now with a basic web frontend and then add a database functionality and then add jquery stuff



question about what i do next:

am i supposed to have the anime classes as managed java beans or can i keep them as they are and just print the data to a jsp page via a servlet controller?

ive been fucking around for a while and ended up with an insane mess and getting no error but it just fails to run with no error specification . at one point i tried to add bean annotations ontop of the xml annotations but it gave me a frowny face and i backed off for the time being

this is what i've got in my head so far:
1) jsp frontend page that takes the user's search string in a form
2) servlet page that takes this and passes it to my service class
3) the service class does GET request and parses the response into the anime objects
4) but then how do i access this data ? does it need to be turned into a java managed bean? can i access it directly from the jsp page? does it need to go through the servlet controller?

ill come back in 8 hours or whatever after i slept

have been trying random stuff but there's tons of stuff to try and that's before i even go to one of the super heavy tutorials .

edit: maybe i make session facade bean from the Ann java class and then use that to do stuff. if it lets me annotate it



OK here is what i've got so far. it runs , time-outs for about 9 seconds, then displays the HTML ("end") ie it doesnt display the object data

ControllerServlet.java
+ Show Spoiler +


ControllerServlet.java

package main;

import entities.Anime;
import entities.Ann;
import entities.Info;
import java.io.IOException;
import java.io.PrintWriter;
import javax.ejb.EJB;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet(name = "ControllerServlet", urlPatterns = {"/ControllerServlet"})
public class ControllerServlet extends HttpServlet {

@EJB
private AnnJAXB annJAXB = new AnnJAXB();

@EJB
private Ann ann = new Ann();

protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
try (PrintWriter out = response.getWriter()) {
/* TODO output your page here. You may use following sample code. */
out.println("<!DOCTYPE html>");
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet ControllerServlet</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>Servlet ControllerServlet at " + request.getContextPath() + "</h1>");

AnnJAXB.Unmarshalling("evangelion");

for (Anime anime : ann.getAnn()) {

out.println("<h1>ID: " + anime.getId() + "</h1>");
out.println("<h1>Name: " + anime.getName() + "</h1>");

for (Info temp : anime.getAnime()) {
if (temp.getSrc() != null) {
out.println("<h1>Info: " + temp.getSrc() + "</h1>");
}
}
}

out.println("<h1>End</h1>");
out.println("</body>");
out.println("</html>");
}
}


AnnJAXB.java
+ Show Spoiler +


package main;

import entities.*;
import javax.xml.bind.*;
import java.io.*;
import java.net.URL;
import javax.ejb.Stateless;

@Stateless
public class AnnJAXB {

public static void Unmarshalling(String searchString) {
try {

JAXBContext jc = JAXBContext.newInstance(Ann.class);
Unmarshaller ums = jc.createUnmarshaller();
URL url = new URL( "http://cdn.animenewsnetwork.com/encyclopedia/api.xml?title=~"+searchString );

Ann ann = (Ann) ums.unmarshal(url);


} catch (Exception e) {
System.out.println(e.getMessage());
}
}
}



when i remove the line AnnJAXB.Unmarshalling("evangelion"); it runs and displays the html instantly, so that bit there is causing it to time out and return nothing from it.

the obvious problem is in AnnJAXB at the line

Ann ann = (Ann) ums.unmarshal(url);

for this it says Variable ann is not used

the other bit that looks weird is
 @EJB
private AnnJAXB annJAXB = new AnnJAXB();

@EJB
private Ann ann = new Ann();
bit


posted to stackoverflow, easier to read http://stackoverflow.com/questions/29674404/mvc-object-method-and-serlvet-structure-help-in-java-please


i tried changing AnnJAXB Unmarshall to return an Ann instead of being static void method. i managed to get it to work eventually but its still hanging like previous version then not displaying the object data.

controllerservlet
+ Show Spoiler +


package main;

import entities.Anime;
import entities.Ann;
import entities.Info;
import java.io.IOException;
import java.io.PrintWriter;
import javax.ejb.EJB;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


/**
*
* @author J
*/
@WebServlet(name = "ControllerServlet", urlPatterns = {"/ControllerServlet"})
public class ControllerServlet extends HttpServlet {

// @EJB
// private AnnJAXB annJAXB = new AnnJAXB();

@EJB
private Ann ann;

/**
* Processes requests for both HTTP <code>GET</code> and <code>POST</code>
* methods.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
try (PrintWriter out = response.getWriter()) {
/* TODO output your page here. You may use following sample code. */
out.println("<!DOCTYPE html>");
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet ControllerServlet</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>Servlet ControllerServlet at " + request.getContextPath() + "</h1>");

AnnJAXB an = new AnnJAXB();
try{
an.Unmarshalling("evangelion");
}catch(Exception e){}

for (Anime anime : ann.getAnn()) {

out.println("<h1>ID: " + anime.getId() + "</h1>");
out.println("<h1>Name: " + anime.getName() + "</h1>");

for (Info temp : anime.getAnime()) {
if (temp.getSrc() != null) {
out.println("<h1>Info: " + temp.getSrc() + "</h1>");
}
}
}

out.println("<h1>End</h1>");
out.println("</body>");
out.println("</html>");
}
}



annjaxb

+ Show Spoiler +


package main;

import entities.*;
import javax.xml.bind.*;
import java.io.*;
import java.net.URL;
import java.net.MalformedURLException;
import javax.ejb.Stateless;

@Stateless
public class AnnJAXB {

public Ann Unmarshalling(String searchString) throws JAXBException, MalformedURLException {


JAXBContext jc = JAXBContext.newInstance(Ann.class);
Unmarshaller ums = jc.createUnmarshaller();
URL url = new URL( "http://cdn.animenewsnetwork.com/encyclopedia/api.xml?title=~"+searchString );


Ann ann = (Ann) ums.unmarshal(url);

return ann;
}
}



i have no words

[image loading]
Cool BW Music Vid - youtube.com/watch?v=W54nlqJ-Nx8 ~~~~~ ᕤ OYSTERS ᕤ CLAMS ᕤ AND ᕤ CUCKOLDS ᕤ ~~~~~~ ༼ ᕤ◕◡◕ ༽ᕤ PUNCH HIM ༼ ᕤ◕◡◕ ༽ᕤ
Manit0u
Profile Blog Joined August 2004
Poland17243 Posts
April 16 2015 19:25 GMT
#12276
On April 16 2015 10:53 FFGenerations wrote:
btw is it normal for netbeans to ramp up to 1,300,000 memory lol


*reads the word "netbeans"*

*averts his eyes*
Time is precious. Waste it wisely.
FFGenerations
Profile Blog Joined April 2011
7088 Posts
Last Edited: 2015-04-16 22:38:54
April 16 2015 22:38 GMT
#12277
OK so the animenewsnetwork is online again now so I can finally test what I was doing all that time. It loads without timing out but nothing in the For loop , neither the html nor the Ann attributes, are displayed.

I posted a well-formatted version to http://stackoverflow.com/questions/29687169/accessing-an-instance-of-an-object-from-a-serlvet-in-java-web-application

If you could have a glimpse that would be awesome :/

I just woke up so gonna take another look in a min
Cool BW Music Vid - youtube.com/watch?v=W54nlqJ-Nx8 ~~~~~ ᕤ OYSTERS ᕤ CLAMS ᕤ AND ᕤ CUCKOLDS ᕤ ~~~~~~ ༼ ᕤ◕◡◕ ༽ᕤ PUNCH HIM ༼ ᕤ◕◡◕ ༽ᕤ
berated-
Profile Blog Joined February 2007
United States1134 Posts
Last Edited: 2015-04-16 23:06:49
April 16 2015 23:06 GMT
#12278
On April 17 2015 07:38 FFGenerations wrote:
OK so the animenewsnetwork is online again now so I can finally test what I was doing all that time. It loads without timing out but nothing in the For loop , neither the html nor the Ann attributes, are displayed.

I posted a well-formatted version to http://stackoverflow.com/questions/29687169/accessing-an-instance-of-an-object-from-a-serlvet-in-java-web-application

If you could have a glimpse that would be awesome :/

I just woke up so gonna take another look in a min


Are those your only 3 classes in SO. It's kind of hard to troubleshoot code without being able to run it. Did someone already talk to you about possibly putting your stuff on github or something if you want more help?

Edit: Definitely not your only 3 classes. See question above
FFGenerations
Profile Blog Joined April 2011
7088 Posts
Last Edited: 2015-04-16 23:16:17
April 16 2015 23:15 GMT
#12279
hey dude, here is a zip file with the project (if google drive lets you share zipped code)

https://drive.google.com/file/d/0BzIvzoW04fGQbUdMT3RYVXN5ODA/view?usp=sharing


i got stuck trying to get git to work a while back and havent tried to use it since. i will sort that out sometime
Cool BW Music Vid - youtube.com/watch?v=W54nlqJ-Nx8 ~~~~~ ᕤ OYSTERS ᕤ CLAMS ᕤ AND ᕤ CUCKOLDS ᕤ ~~~~~~ ༼ ᕤ◕◡◕ ༽ᕤ PUNCH HIM ༼ ᕤ◕◡◕ ༽ᕤ
FFGenerations
Profile Blog Joined April 2011
7088 Posts
Last Edited: 2015-04-16 23:34:05
April 16 2015 23:26 GMT
#12280
STOP I FIXED IT HOLY FUCKING CHRIST


I changed the loop to say:
+ Show Spoiler +

 for (Anime anime : annj.Unmarshalling("evangelion").getAnn()) {


and removed

 annj.Unmarshalling("evangelion");


so it looks like


try{
for (Anime anime : annj.Unmarshalling("evangelion").getAnn()) {

out.println("<h1>Loop1</h1>");

out.println("<h1>ID: " + anime.getId() + "</h1>");
out.println("<h1>Name: " + anime.getName() + "</h1>");

for (Info temp : anime.getAnime()) {
if (temp.getSrc() != null) {
out.println("<h1>Info: " + temp.getSrc() + "</h1>");
}
}
}}catch(Exception e){}

out.println("<h1>End</h1>");
out.println("</body>");
out.println("</html>");


pic

+ Show Spoiler +

[image loading]
Cool BW Music Vid - youtube.com/watch?v=W54nlqJ-Nx8 ~~~~~ ᕤ OYSTERS ᕤ CLAMS ᕤ AND ᕤ CUCKOLDS ᕤ ~~~~~~ ༼ ᕤ◕◡◕ ༽ᕤ PUNCH HIM ༼ ᕤ◕◡◕ ༽ᕤ
Prev 1 612 613 614 615 616 1031 Next
Please log in or register to reply.
Live Events Refresh
Korean StarCraft League
03:00
Week 77
EnkiAlexander 94
HKG_Chickenman84
davetesta70
IntoTheiNu 52
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Nina 232
PiLiPiLi 14
Dota 2
monkeys_forever751
NeuroSwarm125
febbydoto20
League of Legends
JimRising 840
Heroes of the Storm
Khaldor72
Other Games
summit1g9661
WinterStarcraft615
Livibee114
Organizations
Other Games
BasetradeTV56
StarCraft: Brood War
UltimateBattle 28
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 16 non-featured ]
StarCraft 2
• Berry_CruncH304
• Hupsaiya 76
• LaughNgamezSOOP
• AfreecaTV YouTube
• sooper7s
• intothetv
• Migwel
• Kozan
• IndyKCrew
StarCraft: Brood War
• Diggity5
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
League of Legends
• Lourlo1247
• masondota2466
• Stunt389
Upcoming Events
CranKy Ducklings
5h 7m
RSL Revival
5h 7m
ByuN vs Cham
herO vs Reynor
FEL
11h 7m
RSL Revival
1d 5h
Clem vs Classic
SHIN vs Cure
FEL
1d 7h
BSL: ProLeague
1d 13h
Dewalt vs Bonyth
Replay Cast
2 days
Sparkling Tuna Cup
3 days
The PondCast
4 days
Replay Cast
4 days
[ Show More ]
RSL Revival
5 days
Replay Cast
5 days
RSL Revival
6 days
Liquipedia Results

Completed

BSL 2v2 Season 3
HSC XXVII
Heroes 10 EU

Ongoing

JPL Season 2
BSL Season 20
Acropolis #3
KCM Race Survival 2025 Season 2
CSL 17: 2025 SUMMER
Copa Latinoamericana 4
Championship of Russia 2025
RSL Revival: Season 1
Murky Cup #2
BLAST.tv Austin Major 2025
ESL Impact League Season 7
IEM Dallas 2025
PGL Astana 2025
Asian Champions League '25
BLAST Rivals Spring 2025
MESA Nomadic Masters
CCT Season 2 Global Finals
IEM Melbourne 2025

Upcoming

2025 ACS Season 2: Qualifier
CSLPRO Last Chance 2025
2025 ACS Season 2
CSLPRO Chat StarLAN 3
K-Championship
uThermal 2v2 Main Event
SEL Season 2 Championship
FEL Cracov 2025
Esports World Cup 2025
StarSeries Fall 2025
FISSURE Playground #2
BLAST Open Fall 2025
BLAST Open Fall Qual
Esports World Cup 2025
BLAST Bounty Fall 2025
BLAST Bounty Fall Qual
IEM Cologne 2025
FISSURE Playground #1
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2025 TLnet. All Rights Reserved.